.\" @(#)dc.1 6.1 (Berkeley) %G%
is an arbitrary precision arithmetic package.
Ordinarily it operates on decimal integers,
but one may specify an input base, output base,
and a number of fractional digits to be maintained.
a stacking (reverse Polish) calculator.
input is taken from that file until its end,
then from the standard input.
The following constructions are recognized:
The value of the number is pushed on the stack.
A number is an unbroken string of the digits 0-9.
It may be preceded by an underscore _ to input a
Numbers may contain decimal points.
top two values on the stack are added
The two entries are popped off the stack;
the result is pushed on the stack in their place.
Any fractional part of an exponent is ignored.
top of the stack is popped and stored into
is treated as a stack and the value is pushed on it.
All registers start with zero value.
is treated as a stack and its top value is popped onto the main stack.
top value on the stack is duplicated.
The top value on the stack is printed.
The top value remains unchanged.
interprets the top of the stack as an ascii string,
removes it, and prints it.
All values on the stack and in registers are printed.
If executing a string, the recursion level is
the top value on the stack is popped and the string execution level is popped
treats the top element of the stack as a character string
and executes it as a string of dc commands.
replaces the number on the top of the stack with its scale factor.
puts the bracketed ascii string onto the top of the stack.
top two elements of the stack are popped and compared.
is executed if they obey the stated
replaces the top element on the stack by its square root.
Any existing fractional part of the argument is taken
into account, but otherwise the scale factor is ignored.
interprets the rest of the line as a UNIX command.
All values on the stack are popped.
The top value on the stack is popped and used as the
number radix for further input.
pushes the input base on the top of the stack.
The top value on the stack is popped and used as the
number radix for further output.
pushes the output base on the top of the stack.
the top of the stack is popped, and that value is used as
a non-negative scale factor:
the appropriate number of places
and maintained during multiplication, division, and exponentiation.
The interaction of scale factor,
input base, and output base will be reasonable if all are changed
The stack level is pushed onto the stack.
replaces the number on the top of the stack with its length.
A line of input is taken from the input source (usually the terminal)
An example which prints the first ten values of n! is
which is a preprocessor for
providing infix notation and a C-like syntax
which implements functions and reasonable control
`x is unimplemented' where x is an octal number.
`stack empty' for not enough elements on the stack to do what was asked.
`Out of space' when the free list is exhausted (too many digits).
`Out of headers' for too many numbers being kept around.
`Out of pushdown' for too many items on the stack.
`Nesting Depth' for too many levels of nested execution.