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