Golang:计算一个数的反对数

huangapple go评论84阅读模式
英文:

Golang: Computing Anti-log of a number

问题

我想知道你是如何计算一个数的反对数的。

英文:

I wanted to know how it is that you compute the anti-log of a number.

答案1

得分: 2

使用Pow10()Pow(),具体取决于对数的底数。

如果a = log b (base10),那么以10为底数的a的反对数是b

英文:

Using Pow10() or Pow() depending on the base of your logarithm.

if a = log b (base10), then the anti-log of a to the base 10 is b

答案2

得分: 1

package main

import (
"fmt"
"math"
)

func main() {
for f := 1.0; f < 10; f *= 1.1 {
fmt.Printf("10^%15f == %18f\n", f, math.Pow(10, f))
}
}

英文:

For example:

package main

import (
        &quot;fmt&quot;
        &quot;math&quot;
)

func main() {
        for f := 1.0; f &lt; 10; f *= 1.1 {
                fmt.Printf(&quot;10^%15f == %18f\n&quot;, f, math.Pow(10, f))
        }
}

Playground


Output

10^       1.000000 ==          10.000000
10^       1.100000 ==          12.589254
10^       1.210000 ==          16.218101
10^       1.331000 ==          21.428906
10^       1.464100 ==          29.113874
10^       1.610510 ==          40.785895
10^       1.771561 ==          59.096397
10^       1.948717 ==          88.862208
10^       2.143589 ==         139.183839
10^       2.357948 ==         228.006743
10^       2.593742 ==         392.412163
10^       2.853117 ==         713.044618
10^       3.138428 ==        1375.397963
10^       3.452271 ==        2833.160736
10^       3.797498 ==        6273.332921
10^       4.177248 ==       15040.011538
10^       4.594973 ==       39352.559693
10^       5.054470 ==      113362.727116
10^       5.559917 ==      363008.933932
10^       6.115909 ==     1305897.362804
10^       6.727500 ==     5339492.112719
10^       7.400250 ==    25133324.832458
10^       8.140275 ==   138125842.074790
10^       8.954302 ==   900124188.827650
10^       9.849733 ==  7075101518.596476

huangapple
  • 本文由 发表于 2013年4月13日 17:14:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/15986200.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定