bc is a command line calculator

Very often I need a simple command line calculator to do some simple math for my accounting or economics classes. Usually I don't need anything more complicated than the simple arbitrary precision calculator bc. The bc is very intuitive to use, after you learn to set the precision used in calculations:


This sets the precision to five digits. Unless you define the precision bc will default to integer results which would not provide especially precise results. After setting the precision, bc is very intuitive to use. For example:

mjp@oikos:~$ bc
bc 1.06.94
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.

A lot more information can be found with man bc, as usual.


Ben in Boston said...

passing the -l argument also put it in floating point mode

Mikko said...

True, but then the precision would be too much for me :-)

Rich said...

I know this post is ancient but it's high in the Google results for "bc precision", so just to clarify: -l doesn't put bc in floating point mode, it sets scale=20 (and loads some trig functions).