Numeric literals

Decimal, hex, binary, octal, and scientific notation for integers and floats.

Summary

Integer literals can be written in decimal, hexadecimal (0x), binary (0b), or octal (0o). Underscores are allowed as digit separators anywhere in the literal. Float literals use a decimal point or scientific notation (e/E exponent). On overflow, integers silently promote to arbitrary-precision bigints.

Canonical

42                  -- decimal integer
0xFF                -- hexadecimal (255)
0b1010              -- binary (10)
0o17                -- octal (15)
1_000_000           -- underscores as separators (1000000)

3.14                -- float
1e3                 -- scientific notation (1000.0)
2.5e-3              -- 0.0025

Integers are signed 64-bit (int64_t). On overflow, they automatically promote to arbitrary-precision bigints:

let max = 9223372036854775807   -- 2^63 - 1
println(max + 1)                -- 9223372036854775808 (bigint)
println(2 ** 100)               -- 1267650600228229401496703205376

Floats are IEEE 754 double-precision. Bigints support all arithmetic operators and mix freely with regular ints.