bc is ignoring scale option

前端 未结 2 1287
别那么骄傲
别那么骄傲 2021-02-05 03:34

I can\'t figure out why bc tool sometimes ignores the scale option.

Here is an example:

> echo \'scale=2; 2.777 - 1.4744\' | bc
1.3026
2条回答
  •  囚心锁ツ
    2021-02-05 04:27

    as Carl pointed out, if you check man page, you can find that line. it is about expression explanations. subtraction won't read scale variable. If you want to get the expected result (1.30), you could:

    kent$  echo 'scale=2; (2.777 - 1.4744)/1' | bc 
    1.30
    

    / operation will read scale variable.

提交回复
热议问题