...
Source file src/pkg/math/ldexp.go
1
2
3
4
5 package math
6
7
8
9
10
11
12
13
14 func Ldexp(frac float64, exp int) float64
15
16 func ldexp(frac float64, exp int) float64 {
17
18 switch {
19 case frac == 0:
20 return frac
21 case IsInf(frac, 0) || IsNaN(frac):
22 return frac
23 }
24 frac, e := normalize(frac)
25 exp += e
26 x := Float64bits(frac)
27 exp += int(x>>shift)&mask - bias
28 if exp < -1075 {
29 return Copysign(0, frac)
30 }
31 if exp > 1023 {
32 if frac < 0 {
33 return Inf(-1)
34 }
35 return Inf(1)
36 }
37 var m float64 = 1
38 if exp < -1022 {
39 exp += 53
40 m = 1.0 / (1 << 53)
41 }
42 x &^= mask << shift
43 x |= uint64(exp+bias) << shift
44 return m * Float64frombits(x)
45 }
46
View as plain text