Number Bases
Literals in other bases use the prefixes 0x, 0b, and 0o. A _ may be
inserted anywhere in a numeric literal for readability — the compiler ignores
it:
Hexadecimal, binary, octal, and _ digit separators.
03-numbers-hex-bin-oct.zolo
// Feature: Numeric bases and separators
// Syntax: `0x` (hex), `0b` (bin), `0o` (octal); `_` visual separator
// When to use: bitmasks, addresses, readable constants.
let hex = 0xFF // 255
let bin = 0b1010 // 10
let oct = 0o755 // 493 (Unix permissions)
// `_` separators are ignored by the lexer; they improve readability.
let million = 1_000_000
let card_num = 1234_5678_9012_3456
let bytes = 0xDEAD_BEEF
print(hex, bin, oct)
print(million)
print(bytes)
// expected: 255 10 493
// 1000000
// 3735928559
See also