You are viewing a single comment's thread. Return to all comments →
printf "%.3f"e"|bc)
printf "%.3f"
e"|bc)
just avoid the scale.
scale
printf "%.3f" will be sufficient
Avoiding scale defaults to scale=0, so that won't work.
scale=0
then whats the use of setting precision in printf
It rounds the number got from bc to 3 decimal points. Bc does no rounding.
As @bewuethr mentions avoiding scale won't work, but if you used bc -l it would as this defaults to scale of 20.
thanks :)
printf "%.3f\n" exp | bc -l)
There is a $ before the parenthesis that is being interpreted in the comment
printf "%.3f" $(echo $exp | bc -l)
Why do you need the "$" before the echo part?
above command not able to write in STDOUT
Arithmetic Operations
You are viewing a single comment's thread. Return to all comments →
printf "%.3f"
e"|bc)
just avoid the
scale
.printf "%.3f"
will be sufficientAvoiding
scale
defaults toscale=0
, so that won't work.then whats the use of setting precision in printf
It rounds the number got from bc to 3 decimal points. Bc does no rounding.
As @bewuethr mentions avoiding scale won't work, but if you used bc -l it would as this defaults to scale of 20.
thanks :)
printf "%.3f\n" exp | bc -l)
There is a $ before the parenthesis that is being interpreted in the comment
Why do you need the "$" before the echo part?
above command not able to write in STDOUT