MPE/iX Shell and Utilities Reference Manual, Vol 1

dc(1) MPE/iX Shell and Utilities dc(1)
- pops the top two values from the stack, subtracts the first popped from the second,
then pushes the result onto the stack. The number of decimal places in the result is
the maximum number of decimal places in the two operands; the scaling factor has
no effect.
* pops the top two values from the stack, multiplies them, then pushes the result onto
the stack. dc normally sets the number of decimal places in the result to the sum of
the decimal places in the two operands; if this is larger than the scaling factor and
also larger than the number of decimal places in both individual operands, the num-
ber of decimal places in the result is the largest of the scaling factor or the number of
decimal places in either operand.
/ pops the top two values from the stack, divides the second popped by the first, then
pushes the result onto the stack. The number of decimal places in the result is equal
to the scaling factor.
% pops the first two values from the stack, divides the second popped by the first, then
pushes the remainder onto the stack. (Mathematically, AB%calculates A modulo
B.) dc determines the number of decimal places in the result by the result of the divi-
sion.
ˆ pops the first two values from the stack, calculates the second popped to the power of
the first, then pushes the result onto the stack. For example,
23ˆ
leaves the value 8 on the stack. The exponent value must be an integer (that is, with
no decimal places). The scaling factor of the result is the scaling factor you get if the
base was multiplied the appropriate number of times.
c clears the stack (that is, pops all the values off and discards them).
d duplicates the value on top of the stack. For example,
d*
duplicates the top value, then does a multiplication. The result is that you square the
value on top of the stack. As another example, you can use d to save the value on top
of the stack in a register while keeping a copy of the value on the stack; in this case,
you’d use d to duplicate the top value, then use s to pop the duplicate value into a
register.
f prints all values on the stack, from top to bottom. (It does not print the contents of
the registers.)
K pushes the current default scaling factor onto the stack.
1-158 Commands and Utilities