@@ -80,8 +80,8 @@ macro_rules! add {
80
80
}
81
81
82
82
// Extract the exponent and significand from the (possibly swapped) a and b.
83
- let mut a_exponent = a_rep >> significand_bits. 0 as usize & max_exponent;
84
- let mut b_exponent = b_rep >> significand_bits. 0 as usize & max_exponent;
83
+ let mut a_exponent = Wrapping ( ( a_rep >> significand_bits. 0 as usize & max_exponent) . 0 as i32 ) ;
84
+ let mut b_exponent = Wrapping ( ( b_rep >> significand_bits. 0 as usize & max_exponent) . 0 as i32 ) ;
85
85
let mut a_significand = a_rep & significand_mask;
86
86
let mut b_significand = b_rep & significand_mask;
87
87
@@ -111,7 +111,7 @@ macro_rules! add {
111
111
112
112
// Shift the significand of b by the difference in exponents, with a sticky
113
113
// bottom bit to get rounding correct.
114
- let align = a_exponent - b_exponent;
114
+ let align = Wrapping ( ( a_exponent - b_exponent) . 0 as <$ty as Float > :: Int ) ;
115
115
if align. 0 != 0 {
116
116
if align < bits {
117
117
let sticky = ( ( b_significand << ( bits - align) . 0 as usize ) . 0 != 0 ) as <$ty as Float >:: Int ;
@@ -131,7 +131,7 @@ macro_rules! add {
131
131
// and adjust the exponent:
132
132
if a_significand < implicit_bit << 3 {
133
133
let shift = ( a_significand. 0 . leading_zeros( )
134
- - ( implicit_bit << 3 ) . 0 . leading_zeros( ) ) as <$ty as Float > :: Int ;
134
+ - ( implicit_bit << 3 ) . 0 . leading_zeros( ) ) as i32 ;
135
135
a_significand <<= shift as usize ;
136
136
a_exponent -= Wrapping ( shift) ;
137
137
}
@@ -143,38 +143,38 @@ macro_rules! add {
143
143
if ( a_significand & implicit_bit << 4 ) . 0 != 0 {
144
144
let sticky = ( ( a_significand & one) . 0 != 0 ) as <$ty as Float >:: Int ;
145
145
a_significand = a_significand >> 1 | Wrapping ( sticky) ;
146
- a_exponent += one ;
146
+ a_exponent += Wrapping ( 1 ) ;
147
147
}
148
148
}
149
149
150
150
// If we have overflowed the type, return +/- infinity:
151
- if a_exponent >= max_exponent {
151
+ if a_exponent >= Wrapping ( max_exponent. 0 as i32 ) {
152
152
return ( <$ty>:: from_repr( ( inf_rep | result_sign) . 0 ) ) ;
153
153
}
154
154
155
155
if a_exponent. 0 <= 0 {
156
156
// Result is denormal before rounding; the exponent is zero and we
157
157
// need to shift the significand.
158
- let shift = one - a_exponent;
158
+ let shift = Wrapping ( ( Wrapping ( 1 ) - a_exponent) . 0 as <$ty as Float > :: Int ) ;
159
159
let sticky = ( ( a_significand << ( bits - shift) . 0 as usize ) . 0 != 0 ) as <$ty as Float >:: Int ;
160
160
a_significand = a_significand >> shift. 0 as usize | Wrapping ( sticky) ;
161
- a_exponent = zero ;
161
+ a_exponent = Wrapping ( 0 ) ;
162
162
}
163
163
164
164
// Low three bits are round, guard, and sticky.
165
- let round_guard_sticky = a_significand & Wrapping ( 0x7 ) ;
165
+ let round_guard_sticky: i32 = ( a_significand. 0 & 0x7 ) as i32 ;
166
166
167
167
// Shift the significand into place, and mask off the implicit bit.
168
168
let mut result = a_significand >> 3 & significand_mask;
169
169
170
170
// Insert the exponent and sign.
171
- result |= a_exponent << significand_bits. 0 as usize ;
171
+ result |= Wrapping ( a_exponent. 0 as <$ty as Float > :: Int ) << significand_bits. 0 as usize ;
172
172
result |= result_sign;
173
173
174
174
// Final rounding. The result may overflow to infinity, but that is the
175
175
// correct result in that case.
176
- if round_guard_sticky. 0 > 0x4 { result += one; }
177
- if round_guard_sticky. 0 == 0x4 { result += result & one; }
176
+ if round_guard_sticky > 0x4 { result += one; }
177
+ if round_guard_sticky == 0x4 { result += result & one; }
178
178
return ( <$ty>:: from_repr( result. 0 ) ) ;
179
179
}
180
180
}
0 commit comments