lundi 8 décembre 2014

Evaluation an expression and rounding up to three decimals


I have an expression "5+50*3/20 + (19*2)/7" I need to round it up to 3 decimal places. The answer to this is 17.92857142857143. When I use the script below it is giving me 17.928. The answer should be 17.929.



read exp
echo "scale=3; $exp" |bc -l


And one more question is how to use printf to do the same task



Aucun commentaire:

Enregistrer un commentaire