首页 > 代码库 > bc命令

bc命令

bc 命令:
     bc 命令是用于命令行计算器。 它类似基本的计算器。 使用这个计算器可以做基本的数学运算。


[tough@localhost expr]$ echo 8*3|bc24[tough@localhost expr]$ echo 8+2|bc10[tough@localhost expr]$ echo "8 -2"|bc6

 

把要计算工的内容放入文件中:

[tough@localhost expr]$ echo "4+5" > cal.txt[tough@localhost expr]$ bc cal.txtbc 1.06.95Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty.9

 

进入bc模式:
[tough@localhost expr]$ bcbc 1.06.95Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty.6+286 +286-246*2126/232^4165%325/31
#设置精度scale
=25/31.665/22.50(5^3 - 25)/4 + 126.00quit

 

s (x)  The sine of x, x is in radians.    正玄函数c (x)  The cosine of x, x is in radians.  余玄函数a (x)  The arctangent of x, arctangent returns radians. 反正切函数l (x)  The natural logarithm of x.  log函数(以2为底)e (x)  The exponential function of raising e to the value x.  e的指数函数j (n,x)       The bessel function of integer order n of x.   贝塞尔函数echo "scale=100; a(1)*4" | bc -l  (计算圆周率)