Floating point arithmetic using bc
Monday, March 16th, 2009The bc shell utility that is available on most UNIX/Linux distributions defaults to integer arithmetic (i.e. throws away anything after the comma). To prevent this, you can set the “scale” option in bc. E.g., the following command will return 3.333: echo “scale=3; 10/3″ | bc