github.com/tcnksm/go@v0.0.0-20141208075154-439b32936367/src/math/log10.go (about)

     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.
     4  
     5  package math
     6  
     7  // Log10 returns the decimal logarithm of x.
     8  // The special cases are the same as for Log.
     9  func Log10(x float64) float64
    10  
    11  func log10(x float64) float64 {
    12  	return Log(x) * (1 / Ln10)
    13  }
    14  
    15  // Log2 returns the binary logarithm of x.
    16  // The special cases are the same as for Log.
    17  func Log2(x float64) float64
    18  
    19  func log2(x float64) float64 {
    20  	frac, exp := Frexp(x)
    21  	return Log(frac)*(1/Ln2) + float64(exp)
    22  }