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 de588fe commit 65ece14Copy full SHA for 65ece14
src/gfloat/round.py
@@ -62,16 +62,15 @@ def round_float(
62
# Extract exponent
63
expval = int(np.floor(np.log2(vpos)))
64
65
- assert expval > -1024 + p # not yet tested for float64 near-subnormals
66
-
67
# Effective precision, accounting for right shift for subnormal values
68
if fi.has_subnormals:
69
expval = max(expval, 1 - bias)
70
71
# Lift to "integer * 2^e"
72
expval = expval - p + 1
73
74
- fsignificand = vpos * 2.0**-expval
+ # use ldexp instead of vpos*2**-expval to avoid overflow
+ fsignificand = math.ldexp(vpos, -expval)
75
76
# Round
77
isignificand = math.floor(fsignificand)
0 commit comments