The Go Programming Language

Source file src/pkg/math/pow10.go

     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	// This table might overflow 127-bit exponent representations.
     8	// In that case, truncate it after 1.0e38.
     9	var pow10tab [70]float64
    10	
    11	// Pow10 returns 10**e, the base-10 exponential of e.
    12	func Pow10(e int) float64 {
    13		if e < 0 {
    14			return 1 / Pow10(-e)
    15		}
    16		if e < len(pow10tab) {
    17			return pow10tab[e]
    18		}
    19		m := e / 2
    20		return Pow10(m) * Pow10(e-m)
    21	}
    22	
    23	func init() {
    24		pow10tab[0] = 1.0e0
    25		pow10tab[1] = 1.0e1
    26		for i := 2; i < len(pow10tab); i++ {
    27			m := i / 2
    28			pow10tab[i] = pow10tab[m] * pow10tab[i-m]
    29		}
    30	}

release.r60.3. Except as noted, this content is licensed under a Creative Commons Attribution 3.0 License.