Templet:Rnd/b1
This is an auxiliary template of Template:Rnd, called if the number, after rounding, is positive. Thus this description is about internal details only.
Its first parameter is the result of regular rounding with #expr and the function round (but if written in scientific format, as expression not always evaluating to the exact round number, see below), its second the rounding parameter, and its third the value of the condition that the rounding parameter is positive.
It calls one of the following templates, passing on the first and second parameter:
- Template:Rnd/c2dec1
- Template:Rnd/c4dec0
- Template:Rnd/c4dec1
- Template:Rnd/c6dec0
- Template:Rnd/c6dec1
- Template:Rnd/c8dec0
- Template:Rnd/c8dec1 (redirecting to the previous one)
where the last digit is the value of the condition that the rounding parameter is positive, and the digit after the c depends on the range of the rounded number:
- less than 1e-4: 2 (only possible if the rounding parameter is positive)
- from 1e-4 to 1e5: 4
- from 1e5 to 1e9: 6 if the number is a multiple of 1e5, otherwise 4
- 1e9 or more: 8
Multiples of 1e5 between 1e5 and 1e9 are treated separately to avoid scientific notation.
Examples
senisim{{rnd/b1|.0008|5|1}}
→ 0.00080{{rnd/b1|1E+5|-5|0}}
→ 100000{{rnd/b1|1.2E+6|-5|0}}
→ 1200000{{rnd/b1|4.1E+6|10|1}}
→ 4100000.0000000000{{rnd/b1|1540000000|-5|0}}
→ 1.5400×109{{rnd/b1|1542689271|2|1}}
→ Templet:Rnd/c8dec1
Notes
senisim{{#expr:{{#expr:f}}}}
gives the same string for all floats f for which {{#expr:f}}
mathematically represents the same number, see m:Help:Format produced by expr#Categorizing floats by the mathematical value of the string produced by expr.