DC(1)DC(1)
NAME
dc – desk calculator
SYNOPSIS
DESCRIPTION
The value of the number is pushed on the stack.
A number is an unbroken string of the digits
Add
unhandled troff command .ns
Pop the top of the stack and store into
a register named
unhandled troff command .ns
Push the value in register
Duplicate the top value on the stack.
Print the top value on the stack.
The top value remains unchanged.
Print the values on the stack.
unhandled troff command .ns
Exit the program.
If executing a string, the recursion level is
popped by two.
Under operation
Treat the top element of the stack as a character string
and execute it as a string of
Replace the number on the top of the stack with its scale factor.
Put the bracketed text string on the top of the stack.
Pop and compare the
top two elements of the stack.
Register
Replace 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.
Interpret the rest of the line as a shell command.
Clear the stack.
The top value on the stack is popped and used as the number base for further input.
Push the input base on the top of the stack.
The top value on the stack is popped and used as the number base for further output. In bases larger than 10, each ‘digit’ prints as a group of decimal digits.
Push the output base on the top of the stack.
Pop the top of the stack, and use that value as a non-negative scale factor: the appropriate number of places are printed on output, and maintained during multiplication, division, and exponentiation. The interaction of scale factor, input base, and output base will be reasonable if all are changed together.
Push the stack level onto the stack.
Replace the number on the top of the stack with its length.
A line of input is taken from the input source (usually the terminal) and executed.
Used by
The scale factor set by
+,- max(sa,sb) * min(sa+sb , max(s,sa,sb)) / s % so that dividend = divisor*quotient + remainder; remainder has sign of dividend ^ min(sa×|b|, max(s,sa)) v max(s,sa)
EXAMPLES
Print the first ten values of
[la1+dsa*pla10>y]sy 0sa1 lyx
Print π.
1sq180sr60st2si[3li*1+d1+*3*suli27*12-lq*5lr*+lt 5*/d48+Psy10lqlid2*1-***10lulqli5*2-*lr+lylt*-** srsqlult*stli1+silmx]smlmx
SOURCE
SEE ALSO
DIAGNOSTICS
‘Out of headers’
for too many numbers being kept around.
‘Nesting depth’
for too many levels of nested execution.
BUGS
When the input base exceeds 16,
there is no notation for digits greater than
Past its time.