Integer

An integer can be specified using one of three formats.

Decimal Integer Constants

A decimal integer constant is a stream of digits with non-leading zero, for example:

123valid
A123invalid (begins with non-digit)
0123invalid (begins with zero but is a valid octal)

Octal Integer Constants

An octal integer constant is a stream of digits with a leading zero. The digits 8 and 9 have octal values 10 and 11 respectively. For example:

0456valid (= 302 decimal)
018valid (= 020 octal = 16 decimal)
456invalid (but is a valid decimal)
A456invalid (begins with non-digit)

Hexadecimal Integer Constants

An hexadecimal integer constant is a stream of hexadecimal digits starting with 0x (zero followed by the character x). Letters A to F have the hexadecimal values 10 to 15 respectively. Lowercase letters a to f are equivalent to their corresponding uppercase letters, for instance:

0xABvalid (= 171 decimal)
0x1fvalid (= 31 decimal)
ABinvalid (begins with an alphabet letter)
01finvalid (missing x)

[BACK] [FORWARD] [HOME] [UP] [HELP]