Formatting
to also takes a format: decimal places, significant figures, a display
form, or a rounding step.
1/3 to 2 dp
1/3 to 3 sf
1 to 2 dp
12345.678 to 3 sf
1234567 to scientific
1234567 to engineering
1e-7 to nfdp pads with zeros; sf does not. nf (normal form) forces a full
decimal expansion where smoot would otherwise switch to scientific notation.
nearest rounds to a step, which can be a number or a quantity.
1234.5 to nearest 10
12.347 to nearest 0.05
23 mm to nearest 5 mm
1 yard to nearest mmRounding up, down, and to even
Section titled “Rounding up, down, and to even”A rounding (nearest, dp, sf) rounds to the closest step by default. Add
rounded up for a ceiling, rounded down for a floor, or rounded even to
send an exact half to the even neighbour.
3.14159 to 2 dp rounded up
$37 to nearest $5 rounded down
2.5 to nearest 1 rounded evenA unit’s format: clause can carry a direction too.
unit credit of Currency, format: 2 dp rounded even
2.675 creditFormats chain. A format applied to a multi-unit display rounds the last component.
80 kg to imperial to 0 dp
5 kg to lb, oz to 1 dpA format is a value. Name one and reuse it.
money = 2 dp
style = imperial to 0 dp
1/3 to money
80 kg to styleDisplay-only conversion with as
Section titled “Display-only conversion with as”as changes how one line displays and nothing else. to changes the value
itself. The difference shows when you reuse the name later.
1/3 as 2 dp
a = 1/3 as 2 dp
a * 3
b = 1/3 to 2 dp
b * 3The line naming a still shows the full value, because as applies only
where it is written. A to rounding happens once: b holds 0.33, and sums
that use b are ordinary arithmetic, not rounded again.
as works with units too: 10 m as cm displays centimetres, but the value
stays 10 m for later arithmetic.
Document defaults
Section titled “Document defaults”A default line at the top of a document sets a knob for every line below
it.
default format: 2 dp
355 / 113
1 / 7| Knob | Values |
|---|---|
default format: | 2 dp, 3 sf, scientific |
default separator: | comma, underscore |
default grouping: | thousand, lakh, none |
default timezone: | an IANA zone such as Europe/Berlin |
default unit group: | metric, imperial, us |
Grouping is on by default. A per-line to always wins over a default.