An interactive desk calculator program that performs arbitrary-precision integer arithmetic (input may be taken from a
file). Normally you don't run dc directly because it's invoked by bc (see bc). dc provides a variety of one-character commands and operators that perform arithmetic; dc works like a Reverse Polish calculator; therefore, operators and commands follow the numbers they affect. Operators include
^ (as in C, although
^ signifies exponentiation); some simple commands include:
Print current result.
Clear all values on the stack.
Take square root.
Change input base; similar to bc's ibase.
Change output base; similar to bc's obase.
Set scale factor (number of digits after decimal); similar to bc's scale.
Remainder of line is a Unix command.
3 2 ^ pEvaluate 3 squared, then print result 9
8 * pCurrent value (9) times 8, then print result 72
47 - pSubtract 47 from 72, then print result 25
v pSquare root of 25, then print result 5
2 o pDisplay current result in base 2 101
Spaces aren't needed except between numbers.