bc
bc 命令:
bc 命令是用于命令行计算器。 它类似基本的计算器。 使用这个计算器可以做基本的数学运算。
语法:
-
bc [命令开关]
命令开关:
-c 仅通过编译。 bc命令的输出被发送到标准输出。
-l 定义数学函数并且初始化值为20,取代默认值0。
filename 文件名,它包含用于计算的计算器命令,这不是必须的命令。
示例:
簡單好用的計算機: bc
如果我想要使用簡單的計算器呢?很容易呀!就使用 bc 即可!在輸入 bc 之後, 顯示出版本資訊之後,就進入到等待指示的階段。如下所示:
• + 加法
• - 減法
• * 乘法
• / 除法
• ^ 指數
• % 餘數
因為 bc 預設僅輸出整數,如果要輸出小數點下位數,那麼就必須要執行 scale=number ,那個 number 就是小數點位數,例如:
scale=3 <==沒錯!就是這裡!! 1/3 .333 Quit #离开计算器
MATH LIBRARY
If bc is invoked with the -l option, a math library is preloaded and the default scale is set to 20.
The math functions will calculate their results to the scale set at the time of their call. The math
library defines the following functions:
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. 贝塞尔函数
来自 <http://blog.chinaunix.net/uid-23929712-id-2650421.html>

浙公网安备 33010602011771号