In Syntax§
See primary documentation in context for Number literals
Number literals are generally specified in base ten (which can be specified literally, if needed, via the prefix 0d
), unless a prefix like 0x
(hexadecimal, base 16), 0o
(octal, base 8) or 0b
(binary, base 2) or an explicit base in adverbial notation like :16<A0>
specifies it otherwise. Unlike other programming languages, leading zeros do not indicate base 8; instead a compile-time warning is issued.
In all literal formats, you can use underscores to group digits, although they don't carry any semantic information; the following literals all evaluate to the same number:
1000000 1_000_000 10_00000 100_00_00