ddcc -- Command

Desk calculator
ddcc [_f_i_l_e]

ddcc  is an  arbitrary  precision desk  calculator. It  simulates a  stacking
calculator  with ancillary  registers.  Input  must  be entered  in reverse
Polish notation.  ddcc maintains the expected number of decimal places during
addition,  subtraction,  and  multiplication, but  the  user  must make  an
explicit request to maintain any places at all during division.

ddcc reads  input from _f_i_l_e if  specified, and then from  the standard input.
ddcc accepts an arbitrary number  of commands per line; moreover, spaces need
not be left between them.

The _s_c_a_l_e  _f_a_c_t_o_r of a number  is the number of places to  the right of its
decimal  point.   The  _s_c_a_l_e _f_a_c_t_o_r  _r_e_g_i_s_t_e_r  controls  decimal places  in
calculations.  The  scale factor does  not affect addition  or subtraction.
It affects multiplication  only if the sum of the  scale factors of the two
operands is greater  than it.  The result of every  division command has as
many decimal  places as  it specifies.   It affects exponentiation  in that
multiplication  is performed  as  many times  as  the integer  part of  the
exponent indicates; any fractional part of the exponent is ignored.

ddcc recognizes the following commands and constructions:

_n_u_m_b_e_r
     Stack the value of _n_u_m_b_e_r. A  number is a string of symbols taken from
     the digits  `0' through `9',  and the capital letters  `A' through `F'
     (usual  hexadecimal notation),  with  an optional  decimal point.   An
     underscore `_'  as a prefix indicates a  negative number.  The letters
     retain  values ten  through 15, respectively,  regardless of  the base
     chosen by the user.

+ - / * % ^
     The arithmetic  operations: addition(+),  subtraction(-), division(/),
     multiplication(*), remainder(%),  and exponentiation(^).  ddcc  pops the
     two top stack elements,  performs the desired operation by calling the
     multiprecision  routine desired  (see mmuullttiipprreecciissiioonn  aarriitthhmmeettiicc), and
     stacks the result.

cc    Clear the stack.

dd    Duplicate  the top  of the  stack  (so that  it occupies  the top  two
     positions of the stack).

ff    Print the contents of the stack and the values of all registers.

ii    Remove the  top of the stack  and use its integer  part as the assumed
     input base  (default, ten).  The  new input base must  be greater than
     one and less than 17.

II    Stack the current assumed input base.

kk    Remove the  top of the stack  and put it in  the internal scale factor
     register.

KK    Put  the value  of the  internal scale register  (which the  kk command
     sets) on the top of the stack.

ll _x  Load the  value of register _x  to the top of the  stack.  The value of
     register _x is unaltered.  _x may be any character.

oo    Remove the  top of the stack  and use its integer  part as the assumed
     output base  (default, ten).  The  specified base may  be any positive
     integer.

OO    Stack the current assumed output base.

pp    Print the top of the stack.  The value remains on the stack.

qq    Quit the program; control returns to the shell sshh.

ss _x  Remove the top  of the stack and store it  in register _x. The previous
     contents of _x are overwritten.  _x may be any character.

vv    Replace the top of the stack by its square root.

xx    Remove the  top of the  stack, interpret it  as a string  containing a
     sequence of ddcc commands, and execute it.

XX    Replace the top of the stack  by its scale factor (i.e., the number of
     decimal places it has).

zz    Place the number of occupied levels of the stack on top of the stack.

[...]
     Place the bracketed character string  on top of the stack.  The string
     may be executed subsequently with the xx command.

<_x >_x =_x !<_x !>_x !=_x
     Remove the top  two elements of the stack and  compare them.  If there
     is no  `!' sign  before the  relation, execute register  _x if  the two
     elements  obey  the  relation.  If  a  `!'  sign  is present,  execute
     register _x if the elements do not obey the relation.

!    Interpret the rest  of the line as a command  to the shell sshh. Control
     returns to ddcc after command execution terminates.

_E_x_a_m_p_l_e

The following example program  prints the first 20 Fibbonacci numbers.  The
character ll is printed in boldface to help you tell from a numeric one.

    1sa1sb1sc
    [llallbdsa+psbllc1+dsc21<y]sy
    llyx

_S_e_e _A_l_s_o
bbcc, ccoommmmaannddss

_N_o_t_e_s
For most  purposes the  infix notation  of bbcc is  more convenient  than the
Polish notation of ddcc.
