Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought



DC(1)           DOMAIN/IX Reference Manual (SYS5)           DC(1)



NAME
     dc - desk calculator

USAGE
     dc [ file ]

DESCRIPTION
     Dc is an arbitrary-precision arithmetic package.  It nor-
     mally operates on decimal integers, but you may specify an
     input base, output base, and a number of fractional digits
     to be maintained.  Bc (1) is the preprocessor to this pack-
     age, providing infix notation, a C-like syntax that imple-
     ments functions, and reasonable control structures for pro-
     grams.  Dc is, fundamentally, a stacking calculator.  If an
     argument is given, input is taken from that file until its
     end, then from the standard input.

OPERATORS
     number         The value of the number pushed on the stack.
                    A number is an unbroken string of the digits
                    0-9.  May be preceded by an underscore (_) to
                    signify a negative number.  May contain
                    decimal points.

     + - / * % ^    Add (+), subtract (-), multiply (*), divide
                    (/), remainder (%), or exponentiate (^) the
                    top two values on the stack.  Pop the two
                    entries off the stack; push the result on the
                    stack in their place.  Ignore any fractional
                    part of an exponent.

     sx             Pop the top of the stack and store it in a
                    register named x, where x may be any charac-
                    ter.  If the s is capitalized, treat x as a
                    stack and the value is pushed on it.

     lx             Push the value in register x to the stack.
                    The register x remains unaltered.  All regis-
                    ters start with zero value.  If the l is cap-
                    italized, register x is treated as a stack
                    and its top value is popped onto the main
                    stack.

     d              Duplicate the top value on the stack.

     p              Print the top value on the stack.  Do not
                    change the top value.

     P              Interpret top of the stack as an ASCII
                    string, remove the string, and then print it.

     f              Print all values on the stack.



Printed 6/10/85                                              DC-1





DC(1)           DOMAIN/IX Reference Manual (SYS5)           DC(1)



     q              Exit the program.  If executing a string, pop
                    the recursion level by two.

     Q              Pop the top value on the stack and the string
                    execution level by that value.

     x              Treat the top element of the stack as a char-
                    acter string, and execute it as a string of
                    dc commands.

     X              Replace the number on the top of the stack
                    with its scale factor.

     [ ... ]        Put the bracketed ASCII string onto the top
                    of the stack.

     <x   >x   =x
                    Pop the top two elements of the stack and
                    compare them.  Evaluate register x if the
                    elements obey the stated relation.

     v              Replace the top element on the stack by its
                    square root.  Take any existing fractional
                    part of the argument into account, but other-
                    wise ignore the scale factor.

     !              Interpret the rest of the line as a UNIX sys-
                    tem command.

     c              Pop all values on the stack.

     i              Pop the top value on the stack and use it as
                    the number radix for further input.  Push the
                    input base on top of the stack.

     o              Pop the top value on the stack and use it as
                    the number radix for further output.

     O              Push the output base on top of the stack.

     k              Pop the top of the stack and use that value
                    as a non-negative scale factor.  Print the
                    appropriate number of places output, and
                    maintain them during multiplication, divi-
                    sion, and exponentiation.  The interaction of
                    scale factor, input base, and output base is
                    reasonable if all are changed together.

     z              Push the stack level onto the stack.

     Z              Replace the number on the top of the stack
                    with its length.



DC-2                                              Printed 6/10/85





DC(1)           DOMAIN/IX Reference Manual (SYS5)           DC(1)



     ?              Take a line of input from the input source
                    (usually the terminal) and execute it.

     ; :            Used by bc for array operations.

EXAMPLE
     This example prints the first ten values of n!:

        [la1+dsa*pla10>y]sy
        0sa1
        lyx

DIAGNOSTICS
     ``x is unimplemented''
                         x is an octal number.

     ``Stack empty''     Not enough elements on the stack to do
                         function.

     ``Out of space''    Free list is exhausted (too many
                         digits).

     ``Out of headers''  Too many numbers being retained.

     ``Out of pushdown'' Too many items on the stack.

     ``Nesting Depth''   Too many levels of nested execution.

RELATED INFORMATION
     bc (1).

























Printed 6/10/85                                              DC-3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026