Why do I see a difference in the results for the following code:
read a
printf "%.3f\n" $(bc -l <<< "$a")
RESULT: 17.929 and
read a
echo "scale=3; $a" | bc -l
RESULT: 17.928
My input expression is 5+50*3/20 + (19*2)/7.
They seem to be doing the same thing, but the end result is different. Why?
What change(making use of echo) can I make in the second snippet above to get the same result as the first snippet?
17.9285...so basically one solution is just dropping everything after the 8 resulting in17.928while the other solution uses rounding rules, which results in17.929.