DC(1) | User Commands | DC(1) |
dc - desk calculator
/usr/bin/dc [filename]
/usr/xpg6/bin/dc [filename]
dc 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. The overall structure of dc is a stacking (reverse Polish) calculator. If an argument is given, input is taken from that file until its end, then from the standard input.
bc is a preprocessor for dc that provides infix notation and a C-like syntax that implements functions. bc also provides reasonable control structures for programs. See bc(1).
The following constructions are recognized under both /usr/bin/dc and /usr/xpg6/bin/dc:
number
sx
lx
d
p
P
f
q
Q
x
X
[ ... ]
<x >x =x
v
!
c
i
I
o
O
k
K
z
Z
?
Y
; :
The following construction is recognized under /usr/bin/dc, using the scale of whatever the result is.
+ − / * % ^
The following construction is recognized under /usr/xpg6/bin/dc. The results of division are forced to be a scale of 20.
+ − / * % ^
Ensures that the scale set prior to division is the scale of the result.
Example 1 Printing the first ten values of n!
This example prints the first ten values of n!:
[la1+dsa*pla10>y]sy 0sa1 lyx
x is unimplemented
out of space
out of stack space
empty stack
nesting depth
divide by 0
sqrt of neg number
exp not an integer
exp too big
input base is too large
input base is too small
output base is too large
invalid scale factor
scale factor is too large
symbol table overflow
invalid index
index is too large
August 29, 2003 | OmniOS |