File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -94,16 +94,18 @@ def round_float(
94
94
else (isignificand != 0 and _isodd (expval + bias ))
95
95
)
96
96
97
- # fmt: off
98
- should_round_away = (
99
- (rnd == RoundMode .TowardPositive and not sign and delta > 0 )
100
- or (rnd == RoundMode .TowardNegative and sign and delta > 0 )
101
- or (rnd == RoundMode .TiesToAway and delta >= 0.5 )
102
- or (rnd == RoundMode .TiesToEven and delta > 0.5 )
103
- or (rnd == RoundMode .TiesToEven and delta == 0.5 and code_is_odd )
104
- or (rnd == RoundMode .Stochastic and delta > (0.5 + srbits ) * 2.0 ** - srnumbits )
105
- )
106
- # fmt: on
97
+ if rnd == RoundMode .TowardZero :
98
+ should_round_away = False
99
+ if rnd == RoundMode .TowardPositive :
100
+ should_round_away = not sign and delta > 0
101
+ if rnd == RoundMode .TowardNegative :
102
+ should_round_away = sign and delta > 0
103
+ if rnd == RoundMode .TiesToAway :
104
+ should_round_away = delta >= 0.5
105
+ if rnd == RoundMode .TiesToEven :
106
+ should_round_away = delta > 0.5 or (delta == 0.5 and code_is_odd )
107
+ if rnd == RoundMode .Stochastic :
108
+ should_round_away = delta > (0.5 + srbits ) * 2.0 ** - srnumbits
107
109
108
110
if should_round_away :
109
111
if fi .precision > 1 :
You can’t perform that action at this time.
0 commit comments