3/15/72 DC (I)
NAME dc -- desk calculator
SYNOPSIS dc [file]
DESCRIPTION dc is an arbitrary precision integer arithmetic
package. The overall structure of dc is a stack-
ing (reverse Polish) calculator. The following
constructions are recognized by the calculator:
number
The value of the number is pushed on the
stack. If the number starts with a zero, it
is taken to be octal, otherwise it is decimal.
+ - * / %
The top two values on the stack are added (+),
subtracted (-), multiplied (*), divided (/),
or remaindered (%). The two entries are
popped off of the stack; the result is pushed
on the stack in their place.
sx
The top of the stack is popped and stored into
a register named x, where x may be any charac-
ter.
lx
The value in register x is pushed on the
stack. The register x is not altered.
d
The top value on the stack is pushed on the
stack. Thus the top value is duplicated.
p
The top value on the stack is printed in deci-
mal. The top value remains unchanged.
f
All values on the stack are popped off and
printed in decimal.
q
exits the program.
x
treats the top element of the stack as a char-
acter string and executes it as a string of dc
commands.
!
interprets the rest of the line as a UNIX com-
mand.
r
All values on the stack are popped.
nk
n
A scale factor of 10 is set for all subse-
quent multiplication and division.
new-line
space
ignored.
An example to calculate the monthly, weekly and
hourly rates for a $10,000/year salary.
10000
100* (now in cents)
dsa (non-destructive store)
12/ (pennies per month)
la52/ (pennies per week)
d10* (deci-pennies per week)
375/ (pennies per hour)
f (print all results)
(3) 512
(2) 19230
(1) 83333
FILES --
SEE ALSO --
DIAGNOSTICS (x) ? for unrecognized character x.
(x) ? for not enough elements on the stack to do
what was asked.
"Out of space" when the free list is exhausted.
BUGS f is not implemented
% is not implemented
OWNER rhm