Skip to main content
A scalar number is a plain numeric value with no unit attached: a count, a ratio, a rate, or any dimensionless quantity.

Writing scalars

Behavior

  • Scalars combine with other scalars under the usual arithmetic.
  • A scalar applied to a table operates on every cell: [10; 20; 30] * 1.1.
  • A scalar combined with a unit number scales it: 3 * 5m is a length.
Scalars are held at full precision; see Units and precision. How a scalar is displayed — as a plain number, a percentage, or without separators — is controlled by the variable’s display format, not by the value itself. See Combining types for how scalars combine with other types.

Booleans

TrueMath has no separate boolean type — true and false are named scalar constants equal to 1 and 0. They are interchangeable with the numbers, so you can write whichever reads best:
Comparison and logical operators produce a boolean (the number 1 or 0) and expect one in a condition. Boolean flag arguments — such as descending in sort or beginning_of_period in the finance functions — accept true/false or 1/0. Equality is exact: because true is 1, 1 == true is true but 2 == true is false.
Inside if, &&, ||, and !, the condition must reduce to a scalar. Comparing unit values is fine — 3 m < 5 m yields the scalar 1 — but a bare unit value as the condition (if(5 m; …)) raises an error. A scalar counts as true when its absolute value is at least 0.5, and false otherwise — roughly, “rounds to a nonzero number.” So if(2; …) takes the true branch (even though 2 != true), if(0.4; …) takes the false branch, and if(-1; …) is true. In normal use you pass true/false, 1/0, or a comparison result, where this never comes up.