We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cddcb4c commit af53ab9Copy full SHA for af53ab9
src/gfloat/round.py
@@ -108,15 +108,10 @@ def round_float(
108
should_round_away = delta > (0.5 + srbits) * 2.0**-srnumbits
109
110
if should_round_away:
111
- if fi.precision > 1:
112
- isignificand += 1
113
- else:
114
- # Increment isignificand if zero, else increment exponent
115
- if isignificand == 0:
116
- isignificand = 1
117
118
- assert isignificand == 1
119
- expval += 1
+ # This may increase isignificand to 2**p,
+ # which would require special casing in encode,
+ # but not here, where we reconstruct a rounded value.
+ isignificand += 1
120
121
# Reconstruct rounded result to float
122
result = isignificand * (2.0**expval)
0 commit comments