close

bc stands for basic calculator , is "arbitary precision calculator language" , 

在unix system中 , 我們可以藉由bc來幫我們進行一些數值上的運算 .

bc可以使用在shell script中 , 不過要透過pipeline將一些output做為bc的input:

ex:

echo "5 * 7 / 3;" | bc  

--> output 為11 , 因為在shell script中只能執行整數運算 , 

不過我們可以加入一些property的設定:

echo "scale=2; 5 * 7 / 3;" | bc
--> output為11.66 , scale=2代表精確到小數點第二位.
 
 
arrow
arrow
    文章標籤
    linux bc
    全站熱搜

    JerryCheng 發表在 痞客邦 留言(0) 人氣()