RoundedTo()
A copy rounded to the given number of decimals; the original is unchanged.
Basic examples (2)
# RoundedTo still rounds half-up
? (new stzNumber("2.5")).RoundedTo(0)
# ...and still tidies trailing zeros
? (new stzNumber("12.456")).RoundedTo(4)
# ...and still gets 100.4 right
? (new stzNumber("100.4")).RoundedTo(0)3 12.456 100
run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from numeric_tie_rule_narrated.ring(opens in a new tab)
# 0.5 rounds to 1
? (new stzNumber("0.5")).RoundedTo(0)
# 1.5 rounds to 2
? (new stzNumber("1.5")).RoundedTo(0)
# 2.5 rounds to 3 -- half-even would say 2
? (new stzNumber("2.5")).RoundedTo(0)
# 3.5 rounds to 4
? (new stzNumber("3.5")).RoundedTo(0)
# and a negative tie goes away from zero too
? (new stzNumber("-1.5")).RoundedTo(0)1 2 3 4 -2
run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from numeric_rounding_narrated.ring(opens in a new tab)
Scope (2)
oPi = new stzNumber("12.456")
# asking for more places than exist adds none
? oPi.RoundedTo(4)
# ...however many more
? oPi.RoundedTo(5)
# asking for fewer rounds
? oPi.RoundedTo(2)
# ...and fewer still
? oPi.RoundedTo(1)
# ...down to a whole number
? oPi.RoundedTo(0)
# a value whose places are all zeros tidies to the integer
? (new stzNumber("1.005")).RoundedTo(2)12.456 12.456 12.46 12.5 12 1
run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from numeric_rounding_narrated.ring(opens in a new tab)
# ten point four rounds to ten
? (new stzNumber("10.4")).RoundedTo(0)
# ...not to one
? (new stzNumber("10.4")).RoundedTo(0) != "1"
# a hundred point four rounds to a hundred
? (new stzNumber("100.4")).RoundedTo(0)
# ...and ten point oh four to ten
? (new stzNumber("10.04")).RoundedTo(0)
# a value that rounds to zero says zero
? (new stzNumber("0.125")).RoundedTo(0)
# rounding up past the zero still works
? (new stzNumber("20.6")).RoundedTo(0)
# ...and carries
? (new stzNumber("1000.7")).RoundedTo(0)
# negatives keep their magnitude
? (new stzNumber("-10.4")).RoundedTo(0)10 1 100 10 0 21 1001 -10
run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from numeric_rounding_narrated.ring(opens in a new tab)
The extensions of this method
Each extension, and whether it exists for this method; an extension that exists combines with the others (FindSTCS).
Every example is a test file of the library, run inside the library for this page; only those whose output kept every promise their file wrote are shown.

