Annotation of coherent/a/usr/man/COHERENT/dc, revision 1.1

1.1     ! root        1: 
        !             2: 
        !             3: dc                           Command                           dc
        !             4: 
        !             5: 
        !             6: 
        !             7: 
        !             8: Desk calculator
        !             9: 
        !            10: dc [_f_i_l_e]
        !            11: 
        !            12: dc  is an  arbitrary precision  desk  calculator. It  simulates a
        !            13: stacking calculator with  ancillary registers.  Input must be en-
        !            14: tered in reverse Polish notation.  dc maintains the expected num-
        !            15: ber of  decimal places  during addition, subtraction,  and multi-
        !            16: plication, but the user must make an explicit request to maintain
        !            17: any places at all during division.
        !            18: 
        !            19: dc reads input from file if specified, and then from the standard
        !            20: input.   dc accepts  an arbitrary  number  of commands  per line;
        !            21: moreover, spaces need not be left between them.
        !            22: 
        !            23: The scale factor of a number is the number of places to the right
        !            24: of its decimal point.  The scale factor register controls decimal
        !            25: places in  calculations.  The scale factor  does not affect addi-
        !            26: tion or  subtraction.  It affects multiplication  only if the sum
        !            27: of the scale factors of the two operands is greater than it.  The
        !            28: result of every division command has as many decimal places as it
        !            29: specifies.  It  affects exponentiation in  that multiplication is
        !            30: performed as  many times as the integer part  of the exponent in-
        !            31: dicates; any fractional part of the exponent is ignored.
        !            32: 
        !            33: dc recognizes the following commands and constructions:
        !            34: 
        !            35: _n_u_m_b_e_r
        !            36:      Stack the value of number.   A number is a string of symbols
        !            37:      taken from the digits  `0' through `9', and the capital let-
        !            38:      ters `A'  through `F' (usual hexadecimal  notation), with an
        !            39:      optional decimal  point.  An underscore `_'  as a prefix in-
        !            40:      dicates a  negative number.   The letters retain  values ten
        !            41:      through 15,  respectively, regardless of the  base chosen by
        !            42:      the user.
        !            43: 
        !            44: + - / * % ^
        !            45:      The  arithmetic   operations:  addition(+),  subtraction(-),
        !            46:      division(/),  multiplication(*), remainder(%),  and exponen-
        !            47:      tiation(^).  dc  pops the  two top stack  elements, performs
        !            48:      the desired operation  by calling the multiprecision routine
        !            49:      desired  (see  multiprecision  arithmetic), and  stacks  the
        !            50:      result.
        !            51: 
        !            52: cc    Clear the stack.
        !            53: 
        !            54: dd    Duplicate the top of the  stack (so that it occupies the top
        !            55:      two positions of the stack).
        !            56: 
        !            57: ff     Print the  contents  of the  stack  and the  values of  all
        !            58:      registers.
        !            59: 
        !            60: ii    Remove the top of the  stack and use its integer part as the
        !            61:      assumed input base  (default, ten).  The new input base must
        !            62: 
        !            63: 
        !            64: COHERENT Lexicon                                           Page 1
        !            65: 
        !            66: 
        !            67: 
        !            68: 
        !            69: dc                           Command                           dc
        !            70: 
        !            71: 
        !            72: 
        !            73:      be greater than one and less than 17.
        !            74: 
        !            75: II    Stack the current assumed input base.
        !            76: 
        !            77: kk    Remove the top of the stack and put it in the internal scale
        !            78:      factor register.
        !            79: 
        !            80: KK    Put  the value of  the internal scale register  (which the k
        !            81:      command sets) on the top of the stack.
        !            82: 
        !            83: ll _x  Load  the value of register x to  the top of the stack.  The
        !            84:      value of register x is unaltered.  x may be any character.
        !            85: 
        !            86: oo    Remove the top of the  stack and use its integer part as the
        !            87:      assumed output base  (default, ten).  The specified base may
        !            88:      be any positive integer.
        !            89: 
        !            90: OO    Stack the current assumed output base.
        !            91: 
        !            92: pp    Print the top of the stack.  The value remains on the stack.
        !            93: 
        !            94: qq    Quit the program; control returns to the shell sh.
        !            95: 
        !            96: ss _x  Remove the top of the stack and store it in register x.  The
        !            97:      previous  contents  of  x are  overwritten.   x  may be  any
        !            98:      character.
        !            99: 
        !           100: vv    Replace the top of the stack by its square root.
        !           101: 
        !           102: xx    Remove the  top of the stack, interpret it  as a string con-
        !           103:      taining a sequence of dc commands, and execute it.
        !           104: 
        !           105: XX    Replace the top of the  stack by its scale factor (i.e., the
        !           106:      number of decimal places it has).
        !           107: 
        !           108: zz    Place the  number of occupied levels of the  stack on top of
        !           109:      the stack.
        !           110: 
        !           111: [...]
        !           112:      Place the  bracketed character string  on top of  the stack.
        !           113:      The string may be executed subsequently with the x command.
        !           114: 
        !           115: <_x >_x =_x !<_x !>_x !=_x
        !           116:      Remove the  top two elements of the  stack and compare them.
        !           117:      If  there  is  no  `!'  sign  before the  relation,  execute
        !           118:      register x if the two  elements obey the relation.  If a `!'
        !           119:      sign is  present, execute register x if  the elements do not
        !           120:      obey the relation.
        !           121: 
        !           122: !    Interpret the rest of the line as a command to the shell sh.
        !           123:      Control returns to dc after command execution terminates.
        !           124: 
        !           125: ***** Example *****
        !           126: 
        !           127: 
        !           128: 
        !           129: 
        !           130: COHERENT Lexicon                                           Page 2
        !           131: 
        !           132: 
        !           133: 
        !           134: 
        !           135: dc                           Command                           dc
        !           136: 
        !           137: 
        !           138: 
        !           139: The following example program prints the first 20 Fibbonacci num-
        !           140: bers.  The characters 11 and ll are printed in boldface to help you
        !           141: tell them apart.
        !           142: 
        !           143: 
        !           144:         11sa11sb11sc
        !           145:         [llallbdsa+psbllc11+dsc211<y]sy
        !           146:         llyx
        !           147: 
        !           148: 
        !           149: ***** See Also *****
        !           150: 
        !           151: bc, commands
        !           152: 
        !           153: ***** Diagnostics *****
        !           154: 
        !           155: dc produces one of  the following error messages should a problem
        !           156: occur:
        !           157: 
        !           158: 
        !           159:      Stack empty    Not enough stack elements to perform as requested
        !           160:      Out of pushdownNo more room on the stack
        !           161:      Nesting depth  Too many nested execution levels
        !           162:      Out of space   Too many digits demanded
        !           163:      Out of headers Too many numbers being stored
        !           164: 
        !           165: 
        !           166: ***** Notes *****
        !           167: 
        !           168: For most  purposes the  infix notation  of bc is  more convenient
        !           169: than the Polish notation of dc.
        !           170: 
        !           171: 
        !           172: 
        !           173: 
        !           174: 
        !           175: 
        !           176: 
        !           177: 
        !           178: 
        !           179: 
        !           180: 
        !           181: 
        !           182: 
        !           183: 
        !           184: 
        !           185: 
        !           186: 
        !           187: 
        !           188: 
        !           189: 
        !           190: 
        !           191: 
        !           192: 
        !           193: 
        !           194: 
        !           195: 
        !           196: COHERENT Lexicon                                           Page 3
        !           197: 
        !           198: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.