bc is ignoring scale option

前端 未结 2 1283
别那么骄傲
别那么骄傲 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:15

    From the bc(1) man page:

    Unless specifically mentioned the scale of the result is the maximum scale of the expressions involved.

    1.4744 has scale 4, so that's what happens to your expression.

提交回复
热议问题