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 b82ad80 commit 5904633Copy full SHA for 5904633
src/gfloat/round.py
@@ -63,11 +63,10 @@ def round_float(
63
64
else:
65
# Extract significand (mantissa) and exponent
66
- fsignificand, expval = np.frexp(vpos)
67
- assert fsignificand >= 0.5 and fsignificand < 1.0
68
- # Bring significand into range [1.0, 2.0)
69
- fsignificand *= 2
70
- expval -= 1
+ expval = int(np.floor(np.log2(vpos)))
+ fsignificand = vpos * 2.0**-expval
+
+ assert fsignificand >= 1.0 and fsignificand < 2.0
71
72
# Effective precision, accounting for right shift for subnormal values
73
biased_exp = expval + bias
0 commit comments