Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
dc(1) OSS Shell and Utilities Reference Manual
p Prints the top value on the stack. The top value remains unchanged.
P Interprets the top value on the stack as an ASCII string, prints it, and removes it.
q Exits the program. If dc is executing a string, it pops the recursion level by two.
Q Pops the top value on the stack and pop the string execution level by that value.
sx Pops the top value on the stack and stores it in a register named x, where x can be any
single-byte character.
Sx Treats x as a stack: pops the top value on the main stack and pushes that value onto
stack x.
v Replaces the top value on the stack by its square root. Any existing fractional part of
the argument is used, but otherwise the scale factor is ignored.
x Treats the top value on the stack as a character string and executes it as a string of
dc
commands.
X Replaces the top value on the stack by its scale factor.
z Pushes the number of elements in the stack onto the stack.
Z Replaces the top value on the stack with the number of digits in that value.
[string]Putsstring onto the stack.
<x Pops the top two values on the stack and compares them. Register x is executed if the
stated relationship is TRUE.
;: Are used for array operations.
EXAMPLES
1. To use dc as a calculator, proceed as follows:
Enter:
1 4 / p [ Divide 1 by 4 ]
The system responds as follows:
0
Enter:
1 k [ Keep 1 decimal place]s.
14/p
The system responds as follows:
0.2
Enter:
3 k [ Keep 3 decimal places]s.
14/p
The system responds as follows:
0.250
3−6 Hewlett-Packard Company 527188-007