Decimal floating-point literals
A numeric literal containing a decimal point or base-ten exponent is floating-point:
local half = 0.5local avogadro = 6.02e23local small = 2e-3local grouped = 1_000.25Without an expected type, each value above is Float64. An expected annotation selects the format before the literal is rounded:
local compact: Float32 = 1.25local precise: Float64 = 1.25A decimal floating-point literal never implicitly becomes an integer:
local invalid: Int = 1.0 -- type errorDigit separators must sit between digits. Spellings such as 1_000.25_5e1_0 are accepted, while _1.0, 1_.0, 1._0, 1e_2, and 1__0 are rejected.
Ordering
Section titled “Ordering”All four ordering operators require two values of the same numeric type:
local inside = value >= 0.0 and value <= 1.0IEEE comparisons are ordered: <, <=, >, and >= are all false when either operand is NaN. Floating-point division by zero follows IEEE behavior rather than the integer division trap.
Hexadecimal floating-point syntax and ambient-locale decimal punctuation are not part of rc.3.
