...
Source file
src/math/log10.go
Documentation: math
1
2
3
4
5 package math
6
7
8
9 func Log10(x float64) float64 {
10 if haveArchLog10 {
11 return archLog10(x)
12 }
13 return log10(x)
14 }
15
16 func log10(x float64) float64 {
17 return Log(x) * (1 / Ln10)
18 }
19
20
21
22 func Log2(x float64) float64 {
23 if haveArchLog2 {
24 return archLog2(x)
25 }
26 return log2(x)
27 }
28
29 func log2(x float64) float64 {
30 frac, exp := Frexp(x)
31
32
33 if frac == 0.5 {
34 return float64(exp - 1)
35 }
36 return Log(frac)*(1/Ln2) + float64(exp)
37 }
38
View as plain text