File tree Expand file tree Collapse file tree 3 files changed +78
-25
lines changed Expand file tree Collapse file tree 3 files changed +78
-25
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -106,6 +106,8 @@ def round_float(
106
106
should_round_away = delta > 0.5 or (delta == 0.5 and code_is_odd )
107
107
if rnd == RoundMode .Stochastic :
108
108
should_round_away = delta > (0.5 + srbits ) * 2.0 ** - srnumbits
109
+ if rnd == RoundMode .StochasticFast :
110
+ should_round_away = delta > srbits * 2.0 ** - srnumbits
109
111
110
112
if should_round_away :
111
113
# This may increase isignificand to 2**p,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class RoundMode(Enum):
17
17
TiesToEven = 4 #: Round to nearest, ties to even
18
18
TiesToAway = 5 #: Round to nearest, ties away from zero
19
19
Stochastic = 6 #: Stochastic rounding
20
+ StochasticFast = 7 #: Stochastic rounding - possibly faster, but biased.
20
21
21
22
22
23
class FloatClass (Enum ):
You can’t perform that action at this time.
0 commit comments