Normalize normalizes f so that the highest bit of the mantissa is set, and returns the number by which the mantissa was left-shifted.
()
| 197 | // Normalize normalizes f so that the highest bit of the mantissa is |
| 198 | // set, and returns the number by which the mantissa was left-shifted. |
| 199 | func (f *extFloat) Normalize() (shift uint) { |
| 200 | mant, exp := f.mant, f.exp |
| 201 | if mant == 0 { |
| 202 | return 0 |
| 203 | } |
| 204 | if mant>>(64-32) == 0 { |
| 205 | mant <<= 32 |
| 206 | exp -= 32 |
| 207 | } |
| 208 | if mant>>(64-16) == 0 { |
| 209 | mant <<= 16 |
| 210 | exp -= 16 |
| 211 | } |
| 212 | if mant>>(64-8) == 0 { |
| 213 | mant <<= 8 |
| 214 | exp -= 8 |
| 215 | } |
| 216 | if mant>>(64-4) == 0 { |
| 217 | mant <<= 4 |
| 218 | exp -= 4 |
| 219 | } |
| 220 | if mant>>(64-2) == 0 { |
| 221 | mant <<= 2 |
| 222 | exp -= 2 |
| 223 | } |
| 224 | if mant>>(64-1) == 0 { |
| 225 | mant <<= 1 |
| 226 | exp -= 1 |
| 227 | } |
| 228 | shift = uint(f.exp - exp) |
| 229 | f.mant, f.exp = mant, exp |
| 230 | return |
| 231 | } |
| 232 | |
| 233 | // Multiply sets f to the product f*g: the result is correctly rounded, |
| 234 | // but not normalized. |
no outgoing calls
no test coverage detected