Next: ref-syn-trm-flo, Previous: ref-syn-trm-ove, Up: ref-syn-trm [Contents][Index]

The printed form of an integer consists of a sequence of digits
optionally preceded by a minus sign (‘`-`’). These are normally
interpreted as base 10 integers. It is also possible to enter
integers in base 2 (binary), 8 (octal), and 16 (hexadecimal); this is
done by preceding the digit string by the string ‘`0b`’, ‘`0o`’,
or ‘`0x`’ respectively. The characters A-F or a-f stand for digits
greater than 9.
For example, the following tokens all represent the integer fifteen:

15 0b1111 0o17 0xf

Note that

+525

is not a valid integer.

There is also a special notation for character constants. E.g.:

0'A 0'\x41\ 0'\101\

are all equivalent to `65`

(the character code for ‘`A`’).
‘`0'`’ followed by any character except ‘`\`’ (backslash) is
thus read as an integer. If ‘`0'`’ is followed by ‘`\`’, then the
‘`\`’ denotes the start of an escape sequence with special meaning
(see ref-syn-syn-esc).

Send feedback on this subject.