Numeric Literals
Last updated
Last updated
Numbers can be written in various bases. Numbers are assumed to be decimal by default. Non-decimal literals have a specific prefix.
Decimal numbers may contain underscores (_
) to logically separate components.
Underscores are allowed for all numeral systems.
Numeral system
Prefix
Characters
Decimal
None
one or more numbers (0
to 9
)
Binary
0b
one or more zeros or ones (0
or 1
)
Octal
0o
one or more numbers in the range 0
to 7
Hexadecimal
0x
one or more numbers, or characters a
to f
, lowercase or uppercase