Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
User Commands (d - f) dc(1)
NAME
dc - Performs integer arithmetic with arbitrary precision
SYNOPSIS
dc [file]
DESCRIPTION
The dc command is an arbitrary-precision arithmetic calculator.
dc takes its input from file or the
standard input file until it reads an End-of-File character. It writes to the standard output file. dc
operates on integers by default, but you can use subcommands to specify an input base, an output
base, and a number of fractional digits to be maintained.
The bc command is a preprocessor for the dc command. The bc command provides infix nota-
tion and a syntax similar to the C language, which implements functions and reasonable control
structures for programs.
SUBCOMMANDS
number Pushes the specified value onto the stack. number is an unbroken string consisting of
the digits 0 through 9. To specify a negative number, precede number with _ (under-
score). A number can contain a decimal point.
+-*/%ˆ
Adds (+), subtracts (-), multiplies (*), divides (/), remainders (%), or exponentiates (ˆ)
the top two values on the stack. dc pops the top two values off the stack and pushes the
result on the stack in their place.
! Interprets the rest of the line as a system command.
? Executes a line of input from the standard input file.
c Cleans the stack: pops all values on the stack.
d Duplicates the top value on the stack.
f Displays all values on the stack.
i Pops the top value on the stack and uses that value as the number radix for further
input.
I Pushes the input base onto the stack.
k Pops the top value on the stack and uses that value as a nonnegative scale factor. The
appropriate number of places is displayed on output and is maintained during multipli-
cation, division, and exponentiation. The interaction of scale factor, input base, and
output base is reasonable if all are changed together.
lx Pushes the value in register x onto the stack. Register x is not changed. All registers
start with 0 (zero) value.
Lx Treats x as a stack and pops its top value onto the main stack.
o Pops the top value on the stack and uses that value as the number radix for further out-
put.
O Pushes the output base onto the stack.
527188-003 Hewlett-Packard Company 3−5