Node:Integers, Next:, Previous:Terms, Up:Terms



Integers

The constants include integers such as

0   1   999   -512

Besides the usual decimal, or base 10, notation, integers may also be written in other base notations. In sicstus mode, any base from 2 to 36 can be specified, while in iso mode bases 2 (binary), 8 (octal), and 16 (hex) can be used. Letters A through Z (upper or lower case) are used for bases greater than 10. E.g.

15   2'1111   8'17  16'f  % sicstus mode
15   0b1111   0o17  0xf   % iso mode

all represent the integer fifteen. Except for the first, decimal, notation, the forms in the first line are only acceptable in sicstus mode, while those in the second line are only valid in iso mode.

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. Unless character escapes have been switched off, if 0' is followed by \, the \ denotes the start of an escape sequence with special meaning (see Escape Sequences).