MPE/iX Shell and Utilities Reference Manual, Vol 1

dc(1) MPE/iX Shell and Utilities dc(1)
NAME
dc — arbitrary precision desk calculator
SYNOPSIS
dc [file]
DESCRIPTION
dc is a desk calculator program that takes input in reverse Polish notation (see Reverse Polish
Notation later in this man page). If you do not specify a file on the command line, dc reads
input from the standard input; otherwise, it reads input from the file and then from the stan-
dard input (if there is no quit command in the file). dc sends output to the standard output.
There are several types of input:
(a) Numbers are sequences of digits, possibly containing a decimal point. Numbers can
also contain the uppercase characters A through F standing for the hexadecimal (base
16) digits greater than ten; for more on hexadecimal, see the section on Numbers in
Different Bases. Do not break up a number with spaces or commas; for example, you
must write 1000000, not 1,000,000. To create a negative number, put an under-
score (_) immediately before the first digit of the number. Do not use a minus sign (-
) to indicate a negative number; the minus sign has an entirely different meaning in
dc input.
(b) Strings are sequences of characters, enclosed in square brackets. For example,
[abc] is a string which contains the characters abc.
(c) Operators are symbols or characters telling dc to perform some operation; for
example, adding two numbers together.
(d) Register names are single characters. You may use any character as a register name.
An uppercase letter is not the same as the corresponding lowercase one, so register a
is different from register A. A register is a place where dc can store a number or a
string; it is similar to a variable in a programming language. Typically, you use reg-
isters to store values that you want to remember for later use.
(e) Array names follow the same rules as register names. See Array Operations later in
this man page for more details.
You must separate adjacent numbers with at least one white space character. (The white space
characters for dc are the blank, the horizontal tab, and the newline.) You do not need to sepa-
rate other pieces of input from one another, but putting in white space characters makes the
input more readable. As exceptions, register names and array names must immediately follow
the operator that tells what you want to do with the register or array (as described later in this
man page). If you put a white space character after an operator that expects a register or array
name, dc assumes the white space character to be the name.
Commands and Utilities 1-155