Source file
src/math/frexp.go
1
2
3
4
5 package math
6
7
8
9
10
11
12
13
14
15
16
17 func Frexp(f float64) (frac float64, exp int) {
18 if haveArchFrexp {
19 return archFrexp(f)
20 }
21 return frexp(f)
22 }
23
24 func frexp(f float64) (frac float64, exp int) {
25
26 switch {
27 case f == 0:
28 return f, 0
29 case IsInf(f, 0) || IsNaN(f):
30 return f, 0
31 }
32 f, exp = normalize(f)
33 x := Float64bits(f)
34 exp += int((x>>shift)&mask) - bias + 1
35 x &^= mask << shift
36 x |= (-1 + bias) << shift
37 frac = Float64frombits(x)
38 return
39 }
40
View as plain text