* doc/invoke.texi (RS/6000 and PowerPC Options): Document -mhtm and
[official-gcc.git] / libgo / go / math / log10.go
blob2c09d88f2a18b0e2bbe144dc49557b8d9fa7e6ef
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package math
7 // Log10 returns the decimal logarithm of x.
8 // The special cases are the same as for Log.
10 //extern log10
11 func libc_log10(float64) float64
13 func Log10(x float64) float64 {
14 return libc_log10(x)
17 func log10(x float64) float64 {
18 return Log(x) * (1 / Ln10)
21 // Log2 returns the binary logarithm of x.
22 // The special cases are the same as for Log.
24 func Log2(x float64) float64 {
25 return log2(x)
28 func log2(x float64) float64 {
29 frac, exp := Frexp(x)
30 // Make sure exact powers of two give an exact answer.
31 // Don't depend on Log(0.5)*(1/Ln2)+exp being exactly exp-1.
32 if frac == 0.5 {
33 return float64(exp - 1)
35 return Log(frac)*(1/Ln2) + float64(exp)