如何使用 bc 计算数字的对数? [英] How do I calculate the log of a number using bc?
本文介绍了如何使用 bc 计算数字的对数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我第一次使用 bc.我想计算一个数字的对数(以 10 为底).我该怎么办?
This is the first time I am using bc. I want to calculate the log (base 10) of a number. How do I this?
推荐答案
像这样使用 -l
选项调用 bc
(以启用数学库)
Invoke bc
with the -l
option (to enable the math library) like so
$ echo 'l(100)/l(10)' | bc -l
2.00000000000000000000
使用 l
函数,它是自然对数.取您感兴趣的数字的对数,然后除以 10 的自然对数.
Use the l
function which is the natural log. Take the log of the number you are interested in then divide by the natural log of 10.
这篇关于如何使用 bc 计算数字的对数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文