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