All constants in ISO Prolog start with the zero character and there are four types of constants. The character following the zero indicates the type of the constant and then the value.
Thefour different types of constants are: character code-, binary-, octal- and hexadecimal constants.
| Examples | |
| 0'a | this is a character code constant for the character 'a' |
| 0b10101 | a binary number, the number will be converted to the decimal value 21 |
| 0o23463 | this octal constant will be converted to the decimal constant 10035 |
| 0xFFFF | this hexadecimal constant value will be converted to the decimal value 65535 |
A binary constant starts with '0b' and then only 0's and 1's, octal constants start with '0o' and then only characters from the set [0, 1, 2, 3, 4, 5, 6, 7] may follow. Hexadecimal constants start with '0x' and then just characters from the set [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, d, A, B, C, D E, F] follow.
Character constants are very useful when a character like a single quote or a double quote character needs to be used as argument. For instance: put_char( 0'" ). Character code constants are a subset of integers.