Hello world!

January 11, 2010

The bc utility

bc is an arbitrary precision numeric processing language, which can be used to compute simple arithmetic from the command line.

Interesting article on bc. Online manual is available here.

Note: The following examples, were taking from a Solaris 10 system

To generate decimal values:
Note: scale specifies how many digits to the right of the decimal point. The following demonstrates, 2 digits after decimal point:
# echo "scale=2; 701664/1052624" | bc
.66

To use the result of the previous calculation, automatically:
Note:
use the (.) operator
# bc
2*2
4
.*4
16


Follow

Get every new post delivered to your Inbox.