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