Skip to content

Numbers

smoot has one numeric type. Whole numbers stay whole; fractions are exact.

42
3.14
.5
1_000_000
1,000,000
6.022e23
1.5e-3
10 / 3
20 / 4

Large numbers display with thousands grouping. Both _ and , group digits in your source; a comma needs two or three digits after it and no spaces.

Arithmetic is exact, not floating point.

0.1 + 0.2 == 0.3
1 / 3 * 3 == 1
sqrt(2) * sqrt(2) == 2

Numbers show at most four decimal places. A value too small to show at four places keeps four significant figures instead, so it never reads as zero, and very large or very small magnitudes switch to scientific notation. The stored value keeps full precision; see Formatting to choose how much you see. A unit with its own precision keeps it, so money still shows its cents.

A whole number followed by a fraction is a mixed number.

3 1/2
2 1/2 ft

k, hundred, thousand, million, billion, and trillion scale the number before them.

3k
2 hundred
4 thousand
$1.5 million
2 billion