Softanza
StartFrançais
Softanza
Reference · stzNumber

RoundedToHalfEven()

RoundedTo() keeps its historical half-up behaviour, so nothing existing moves; the mode is something you ASK for.

also: banker's rounding round half to even accounting rounding

Basic examples (2)

Softanza
# -1.5 goes away from zero under half-up
? (new stzNumber("-1.5")).RoundedToHalfUp(0)
# ...and to the even digit under half-even
? (new stzNumber("-2.5")).RoundedToHalfEven(0)
# -0.5 rounds to plain 0, not -0
? (new stzNumber("-0.5")).RoundedToHalfEven(0)
# ...and so does -0.4
? (new stzNumber("-0.4")).RoundedToHalfUp(0)
Output
-2
-2
0
0

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)

Softanza
# 9.99 to one place carries into the units
? (new stzNumber("9.99")).RoundedToHalfUp(1)
# 9.999 to none carries twice
? (new stzNumber("9.999")).RoundedToHalfUp(0)
# 99.95 carries through both
? (new stzNumber("99.95")).RoundedToHalfEven(1)
# 19.995 reaches twenty
? (new stzNumber("19.995")).RoundedToHalfUp(2)
# it pads rather than inventing
? (new stzNumber("1.5")).RoundedToHalfEven(3)
# ...and an integer gains a fraction
? (new stzNumber("7")).RoundedToHalfUp(2)
Output
10.0
10
100.0
20.00
1.500
7.00

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)

Scope (3)

Softanza
# 1.005 to two places is 1.01 commercially
? (new stzNumber("1.005")).RoundedToHalfUp(2)
# ...and 1.00 by banker's
? (new stzNumber("1.005")).RoundedToHalfEven(2)
# 0.125 is 0.13 or 0.12
? (new stzNumber("0.125")).RoundedToHalfUp(2)
# ...depending on the rule you named
? (new stzNumber("0.125")).RoundedToHalfEven(2)
# 2.345 splits the same way
? (new stzNumber("2.345")).RoundedToHalfEven(2)
# ...but 0.135 does not, because 3 is odd
? (new stzNumber("0.135")).RoundedToHalfEven(2)
Output
1.01
1.00
0.13
0.12
2.34
0.14

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)

Softanza
# 0.4 goes down under either
? (new stzNumber("0.4")).RoundedToHalfEven(0)
# ...and half-up agrees
? (new stzNumber("0.4")).RoundedToHalfUp(0)
# 0.6 goes up under either
? (new stzNumber("0.6")).RoundedToHalfEven(0)
# ...and half-up agrees
? (new stzNumber("0.6")).RoundedToHalfUp(0)
# 0.51 is more than half, so it rises even under half-even
? (new stzNumber("0.51")).RoundedToHalfEven(0)
# 0.4999 is less than half, so it falls even under half-up
? (new stzNumber("0.4999")).RoundedToHalfUp(0)
# 0.500 IS a tie -- trailing zeros do not change that
? (new stzNumber("0.500")).RoundedToHalfEven(0)
Output
0
0
1
1
1
0
0

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)

Softanza
# half-up sends 0.5 to 1
? (new stzNumber("0.5")).RoundedToHalfUp(0)
# ...1.5 to 2
? (new stzNumber("1.5")).RoundedToHalfUp(0)
# ...2.5 to 3
? (new stzNumber("2.5")).RoundedToHalfUp(0)
# ...and 3.5 to 4
? (new stzNumber("3.5")).RoundedToHalfUp(0)
# half-even sends 0.5 to 0
? (new stzNumber("0.5")).RoundedToHalfEven(0)
# ...1.5 to 2
? (new stzNumber("1.5")).RoundedToHalfEven(0)
# ...2.5 to 2, not 3
? (new stzNumber("2.5")).RoundedToHalfEven(0)
# ...and 3.5 to 4
? (new stzNumber("3.5")).RoundedToHalfEven(0)
Output
1
2
3
4
0
2
2
4

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)

The extensions of this method

Each extension, and whether it exists for this method; an extension that exists combines with the others (FindSTCS).

Extension
Exists
What it adds · The names
Q
yes
does what the method does, then returns the object, so the call can be chained · RoundedToHalfEvenQ
QQ
no
chains on the next, more specific type of object (the Q ladder)
QQQ
no
chains on the most specific type of object (the Q ladder)
QRT
no
returns the result as an object of the requested type
CS
no
takes a case-sensitivity flag
ST
no
takes the position to start from (StartingAt)
IB
no
takes bounds that are included (IncludingBounds)
XT
no
the extended form: more parameters than the base method
XTT
no
yet another extension: a further extended form, after XT
Z
no
includes the position in what it returns
ZZ
no
returns positions as sections, [start, end]
W
no
selects by a condition
WF
no
selects by a condition, with the expressive keywords (@NextItem, @PreviousItem...)
D
no
takes a direction, forward or backward (Directional)
F
no
takes a function (the condition or the update is given as a function); the forms document also uses F for the future form, which defers the action
Many
no
works on a collection of items instead of one (the plural form)
Except
no
takes exceptions, what to leave out (the exceptional form)
U
no
returns the result without duplication

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.

See also