How do I calculate the log of a number using bc?

前端 未结 8 743
说谎
说谎 2020-12-28 11:35

This is the first time I am using bc. I want to calculate the log (base 10) of a number. How do I this?

8条回答
  •  情深已故
    2020-12-28 12:31

    Invoke bc with the -l option (to enable the math library) like so

    $ echo 'l(100)/l(10)' | bc -l
    2.00000000000000000000
    

    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.

提交回复
热议问题