Bc

From LQWiki
Jump to navigation Jump to search

bc is a calculator for the console. It works like this:

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1+1
2
quit
$

By default, numbers are treated as integers, but you can set the number of fraction digits to retain and display by setting the variable scale like this:

 scale=0
 1/3
 0
 scale=5
 1/3
 .33333

As you might guess from this, you can assign values to other variables, and use them in calculations like this:

 foo=1/3
 foo*3
 .99999

This article is a stub and needs to be finished. Plunge forward and help it grow!

See also

  • Console
  • dc - reverse-polish arbitrary precision calculator
  • factor - Factor positive integers.
  • seq - Show number sequences.

External Links