When I run:
fval=1.40 ; echo "scale=0 ; 1000 * ${fval}" | bc
I get the result:
1400.00
With my specified value for scale
, I expect no decimal digits.
Does anyone else have this issue?
Version: bc
1.07.1
Ubuntu 22.04.4 LTS
(Upgrade of Ubuntu MATE from 20.04 LTS to 22.04.04 LTS, not a fresh install)
Not a bug. From
man bc
:And, further down below:
So, the fact that "The scale of the result is the value of the variable scale" is not explicitly stated (unlike when describing
expr / expr
), already means thatexpr * expr
is not expected to honorscale
.Also, the fact that in case of
expr * expr
"the result is the maximum scale of the expressions involved" can be confirmed empirically:To obtain the wanted behavior, you could add a meaningless division (note that since
scale
defaults to 0 you might as well omit it):