LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package math | 5 package math |
6 | 6 |
7 const ( | 7 const ( |
8 » uvnan = 0x7ff8000000000000 | 8 » uvnan = 0x7FF8000000000001 |
9 uvinf = 0x7FF0000000000000 | 9 uvinf = 0x7FF0000000000000 |
10 uvneginf = 0xFFF0000000000000 | 10 uvneginf = 0xFFF0000000000000 |
11 mask = 0x7FF | 11 mask = 0x7FF |
12 shift = 64 - 11 - 1 | 12 shift = 64 - 11 - 1 |
13 bias = 1023 | 13 bias = 1023 |
14 ) | 14 ) |
15 | 15 |
16 // Inf returns positive infinity if sign >= 0, negative infinity if sign < 0. | 16 // Inf returns positive infinity if sign >= 0, negative infinity if sign < 0. |
17 func Inf(sign int) float64 { | 17 func Inf(sign int) float64 { |
18 var v uint64 | 18 var v uint64 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // normalize returns a normal number y and exponent exp | 51 // normalize returns a normal number y and exponent exp |
52 // satisfying x == y × 2**exp. It assumes x is finite and non-zero. | 52 // satisfying x == y × 2**exp. It assumes x is finite and non-zero. |
53 func normalize(x float64) (y float64, exp int) { | 53 func normalize(x float64) (y float64, exp int) { |
54 const SmallestNormal = 2.2250738585072014e-308 // 2**-1022 | 54 const SmallestNormal = 2.2250738585072014e-308 // 2**-1022 |
55 if Abs(x) < SmallestNormal { | 55 if Abs(x) < SmallestNormal { |
56 return x * (1 << 52), -52 | 56 return x * (1 << 52), -52 |
57 } | 57 } |
58 return x, 0 | 58 return x, 0 |
59 } | 59 } |
LEFT | RIGHT |