MPE/iX Shell and Utilities Reference Manual, Vol 1

dc(1) MPE/iX Shell and Utilities dc(1)
dc outputs long numbers with a maximum of 70 characters per line. If a number is longer
than this, dc puts a backslash \ at the end of the line, indicating that the number continues on
the next line.
dc always prints a value of zero as 0, regardless of the output base and regardless of the num-
ber of decimal places that are normally attached to the value.
Some people have trouble figuring out how to put the input base back to base ten after work-
ing in some other base.
Ai
always works, since A stands for the hexadecimal digit ten.
The maximum output base is the maximum integer value that the hardware can represent.
Executing Strings
A string is any sequence of characters. In particular, a string may consist of a sequence of dc
commands.
The x command pops the top value from the stack and executes it as if it were a string con-
taining dc commands. For example, consider the following code:
[lapP lbpP]sz
This pushes the string inside the square brackets onto the stack, and then pops it into register
z. From this point onward, the command
lzx
pushes the string in z onto the stack, then execute the commands inside the string. The
sequence of commands lapP pushes the value of register a onto the stack, prints it, then pops
the value off again. The sequence of commands lbpP does the same for register b. The result
is that we can use lzx to print the current contents of registers a and b any time we want.
There are several other commands for executing strings:
>x pops two values off the stack. If the first popped value is greater than the second, dc
executes the contents of register x as a string of commands. As an example,
la lb >z
executes the string in register z if the contents of register b are greater than the con-
tents of register a.
!>x pops two values off the stack. If the first popped value is not greater than the second,
dc executes the contents of register x as a string of commands.
Commands and Utilities 1-161