Skip to content

Commit 2d3e954

Browse files
committed
Fix round to Positive, Negative
1 parent 29e5564 commit 2d3e954

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/gfloat/round.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def round_float(
8080
isignificand = math.floor(fsignificand)
8181
delta = fsignificand - isignificand
8282
if (
83-
(rnd == RoundMode.TowardPositive and not sign)
84-
or (rnd == RoundMode.TowardNegative and sign)
83+
(rnd == RoundMode.TowardPositive and not sign and delta > 0)
84+
or (rnd == RoundMode.TowardNegative and sign and delta > 0)
8585
or (rnd == RoundMode.TiesToAway and delta >= 0.5)
8686
or (rnd == RoundMode.TiesToEven and delta > 0.5)
8787
or (rnd == RoundMode.TiesToEven and delta == 0.5 and _isodd(isignificand))
@@ -108,6 +108,7 @@ def round_float(
108108
else:
109109
assert isignificand == 1
110110
expval += 1
111+
## End special case for Precision=1.
111112

112113
result = isignificand * (2.0**expval)
113114

0 commit comments

Comments
 (0)