Cópia da wikiespelho

Este é um espelho da wiki em pascal.chat. A edição, o histórico e a entrada ficam lá.

Dollar sign/pt

English · Français · Português · Suomi · Русский

$

Em ASCII, o código decimal de caractere 36 (ou hexadecimal 24) é definido para ser $ (sinal de dólar).

Pascal

O símbolo $, pronúnciado “sinal de dólar”, é usado em Pascal para indicar uma base hexadecimal.\

pascal
program dollarSignDemo(input, output, stderr);

var
    i: longint;

begin
    // '$' bem como '0x' são reconhecidos por readLn
    // como prefixos de base hexadecimal
    readStr('$24', i);
    writeLn(i);    // will print  36
    writeLn(-$24); // will print -36
end.

Um sinal opcional é escrito na frente do indicador de base.

Outras situações

Nos compiladores FPC e Delphi, o sinal de dólar aparece em diretivas de compilação da forma {$directive}.


From the Free Pascal wiki, page "Dollar sign/pt", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revisão 2, última alteração por WikiArchive .