dc(1)

dc(1)

oThe top value on the stack is popped and used as the number radix for further output. See below for notes on output base.

Opushes the output base on the top of the stack.

kthe top of the stack is popped, and that value is used as a non-negative scale factor: the appropriate number of places are printed on output, and maintained during multi- plication, division, and exponentiation. The interaction of scale factor, input base, and output base will be reasonable if all are changed together.

Kpushes the scale factor on the top of the stack.

zThe stack level is pushed onto the stack.

Zreplaces the number on the top of the stack with its length.

?A line of input is taken from the input source (usually the terminal) and executed.

;and : Used by bc for array operations.

YGenerates debugging output for dc itself.

The input base may be any number, but only the digits 0-9 and A-F are available for input, thus limiting the usefulness of bases outside the range 1-16. All 16 possible digits may be used in any base; they always take their conventional values.

The output base may be any number. Bases in the range of 2-16 generate the "usual" results, with the letters A-F representing the values from 10 through 16. Bases 0 and 1 generate a string of 1s whose length is the value of the number. Base −1 generates a similar string consisting of ds. Other bases have each "digit" represented as a (multi-digit) decimal number giving the ordinal of that digit. Each "digit" is signed for negative bases. "Digits" are separated by spaces. Given the de®nition of output base, the command Op always yields "10" (in a representation appropriate to the base); O1-pyields useful information about the output base.

DIAGNOSTICS

Where x is an octal number.

x is unimplemented

stack empty

There are insuf®cient elements on the stack to do what was asked.

Out of space

The free list is exhausted (too many digits).

Out of headers

Too many numbers are being kept around.

Out of pushdown

Too many items are on the stack.

Nesting Depth

There are too many levels of nested execution.

EXAMPLES

This example prints the ®rst ten values of n! (n factorial):

[la1+dsa*pla10>y]sy

0sa1 lyx

SEE ALSO bc(1).

DC: An Interactive Desk Calculator tutorial in Number Processing Users Guide.

d

HP-UX Release 11i: December 2000

− 2 −

Section 1171