I have code like this in Bash :
read a
read b
c=96.0
d=100.0
echo "scale=2;($b*$c - $a*$d)/$a" |bc
And it prints result of this expression :
(b*96-a*100)/a
But when result is between -1 and 0
it gives something like this : -.99
For smaller values it prints result correctly.
So, my question is, how to force program to put 0 when printing
0.123123(…)
? Not only
.123123(…)
Use printf:
printf is (also) a bash builtin