Skip to content

Commit 8b78f72

Browse files
committed
Fix incorrect parenthesis
Also add parenthesis in places to make things mofre clear.
1 parent 4eed0fe commit 8b78f72

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/float/add.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ macro_rules! add {
4343

4444
if a_abs == inf_rep {
4545
// +/-infinity + -/+infinity = qNaN
46-
if a.repr() ^ b.repr() == sign_bit.0 {
46+
if (a.repr() ^ b.repr()) == sign_bit.0 {
4747
return (<$ty as Float>::from_repr(qnan_rep.0));
4848
} else {
4949
// +/-infinity + anything remaining = +/- infinity
@@ -100,7 +100,7 @@ macro_rules! add {
100100
// The sign of the result is the sign of the larger operand, a. If they
101101
// have opposite signs, we are performing a subtraction; otherwise addition.
102102
let result_sign = a_rep & sign_bit;
103-
let subtraction = (a_rep ^ b_rep) & sign_bit != zero;
103+
let subtraction = ((a_rep ^ b_rep) & sign_bit) != zero;
104104

105105
// Shift the significands to give us round, guard and sticky, and or in the
106106
// implicit significand bit. (If we fell through from the denormal path it
@@ -115,7 +115,7 @@ macro_rules! add {
115115
if align.0 != 0 {
116116
if align < bits {
117117
let sticky = ((b_significand << (bits - align).0 as usize).0 != 0) as <$ty as Float>::Int;
118-
b_significand = b_significand >> (align.0 | sticky) as usize;
118+
b_significand = (b_significand >> align.0 as usize) | Wrapping(sticky);
119119
} else {
120120
b_significand = one; // sticky; b is known to be non-zero.
121121
}
@@ -173,8 +173,8 @@ macro_rules! add {
173173

174174
// Final rounding. The result may overflow to infinity, but that is the
175175
// correct result in that case.
176-
if round_guard_sticky > Wrapping(0x4) { result += one; }
177-
if round_guard_sticky == Wrapping(0x4) { result += result & one; }
176+
if round_guard_sticky.0 > 0x4 { result += one; }
177+
if round_guard_sticky.0 == 0x4 { result += result & one; }
178178
return (<$ty>::from_repr(result.0));
179179
}
180180
}

0 commit comments

Comments
 (0)