AWK中的对数的计算 [英] Calculation of logarithm in awk
本文介绍了AWK中的对数的计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在awk中以10为底计算对数?我尝试过
How to compute a logarithm with base 10 in awk? I tried
-2.5*log(10)($2)/log(10)
输出:83051.02180161216529给出了-5.7564,但是应该是-12.29836.谢谢.
The output: 83051.02180161216529 gave -5.7564, but it should be -12.29836. Thank you.
推荐答案
以10为底的对数的正确公式为:
The proper formula for logarithm on base 10 is:
log($2)/log(10)
它给出了正确的答案:
echo 83051.02180161216529 |awk '{print 2.5*log($1)/log(10)}'
12.2984
这篇关于AWK中的对数的计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文