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 2d01e39 commit 247f141Copy full SHA for 247f141
docs/source/05-stochastic-rounding.ipynb
src/gfloat/round_ndarray.py
@@ -91,9 +91,10 @@ def round_ndarray(
91
## RTNE delta to srbits
92
d = delta * 2.0**srnumbits
93
floord = np.floor(d).astype(np.int64)
94
- d = floord + ((d - floord > 0.5) | ((d - floord == 0.5) & _isodd(floord)))
+ dd = d - floord
95
+ drnd = floord + (dd > 0.5) + ((dd == 0.5) & ~_isodd(floord))
96
- should_round_away = d > srbits
97
+ should_round_away = drnd > srbits
98
case RoundMode.StochasticFast:
99
assert srbits is not None
100
should_round_away = delta > (2 * srbits + 1) * 2.0 ** -(1 + srnumbits)
0 commit comments