bc

bc, for basic calculator

 

bc takes the following options from the command line:

-h, --help
Print the usage and exit.
-l, --mathlib
Define the standard math library.
-w, --warn
Give warnings for extensions to POSIX bc.
-s, --standard
Process exactly the POSIX bc language.
-q, --quiet
Do not print the normal GNU bc welcome.
-v, --version
Print the version number and copyright and quit.

 

Calculating pi to 10000 places

Calculate pi using the builtin arctangent function, a().

$ bc -lq
scale=10000
4*a(1) # The atan of 1 is 45 degrees, which is pi/4 in radians.
       # This may take several minutes to calculate.


The bc command supports the following features.
  • Arithmetic operators
  • Increment and decrement operators
  • Assignment operators
  • Comparision or Relational Operators
  • Logical or Boolean operators
  • Math Functions
  • Conditional statements
  • Iterative statements
  • Functions