home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / dc.info (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  11KB  |  208 lines

  1. This is Info file dc.info, produced by Makeinfo-1.52 from the input
  2. file dc.texinfo.
  3.    This file documents DC, an arbitrary precision calculator.
  4.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1984 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that this permission notice may be stated in a
  17. translation approved by the Foundation.
  18. File: dc.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  19. * Menu:
  20. * Introduction::                Introduction
  21. * Printing Commands::           Printing Commands
  22. * Arithmetic::                  Arithmetic
  23. * Stack Control::               Stack Control
  24. * Registers::                   Registers
  25. * Parameters::                  Parameters
  26. * Strings::                     Strings
  27. * Status Inquiry::              Status Inquiry
  28. * Notes::                       Notes
  29. File: dc.info,  Node: Introduction,  Next: Printing Commands,  Prev: Top,  Up: Top
  30. Introduction
  31. ************
  32.    DC is a reverse-polish desk calculator which supports unlimited
  33. precision arithmetic.  It also allows you to define and call macros.
  34. Normally DC reads from the standard input; if any command arguments are
  35. given to it, they are filenames, and DC reads and executes the contents
  36. of the files before reading from standard input.  All output is to
  37. standard output.
  38.    To exit, use `q'.  `C-c' does not exit; it is used to abort macros
  39. that are looping, etc.  (Currently this is not true; `C-c' does exit.)
  40.    A reverse-polish calculator stores numbers on a stack.  Entering a
  41. number pushes it on the stack.  Arithmetic operations pop arguments off
  42. the stack and push the results.
  43.    To enter a number in DC, type the digits, with an optional decimal
  44. point.  Exponential notation is not supported.  To enter a negative
  45. number, begin the number with `_'.  `-' cannot be used for this, as it
  46. is a binary operator for subtraction instead.  To enter two numbers in
  47. succession, separate them with spaces or newlines.  These have no
  48. meaning as commands.
  49. File: dc.info,  Node: Printing Commands,  Next: Arithmetic,  Prev: Introduction,  Up: Top
  50. Printing Commands
  51. *****************
  52.      Prints the value on the top of the stack, without altering the
  53.      stack.  A newline is printed after the value.
  54.      Prints the value on the top of the stack, popping it off, and does
  55.      not print a newline after.
  56.      Prints the entire contents of the stack and the contents of all of
  57.      the registers, without altering anything.  This is a good command
  58.      to use if you are lost or want to figure out what the effect of
  59.      some command has been.
  60. File: dc.info,  Node: Arithmetic,  Next: Stack Control,  Prev: Printing Commands,  Up: Top
  61. Arithmetic
  62. **********
  63.      Pops two values off the stack, adds them, and pushes the result.
  64.      The precision of the result is determined only by the values of
  65.      the arguments, and is enough to be exact.
  66.      Pops two values, subtracts the first one popped from the second
  67.      one popped, and pushes the result.
  68.      Pops two values, multiplies them, and pushes the result.  The
  69.      number of fraction digits in the result is controlled by the
  70.      current precision flag (see below) and does not depend on the
  71.      values being multiplied.
  72.      Pops two values, divides the second one popped from the first one
  73.      popped, and pushes the result.  The number of fraction digits is
  74.      specified by the precision flag.
  75.      Pops two values, computes the remainder of the division that the
  76.      `/' command would do, and pushes that.  The division is done with
  77.      as many fraction digits as the precision flag specifies, and the
  78.      remainder is also computed with that many fraction digits.
  79.      Pops two values and exponentiates, using the first value popped as
  80.      the exponent and the second popped as the base.  The fraction part
  81.      of the exponent is ignored.  The precision flag specifies the
  82.      number of fraction digits in the result.
  83.      Pops one value, computes its square root, and pushes that.  The
  84.      precision flag specifies the number of fraction digits in the
  85.      result.
  86.    Most arithmetic operations are affected by the "precision flag",
  87. which you can set with the `k' command.  The default precision value is
  88. zero, which means that all arithmetic except for addition and
  89. subtraction produces integer results.
  90.    The remainder operation (`%') requires some explanation: applied to
  91. arguments `a' and `b' it produces `a - (b * (a / b))', where `a / b' is
  92. computed in the current precision.
  93. File: dc.info,  Node: Stack Control,  Next: Registers,  Prev: Arithmetic,  Up: Top
  94. Stack Control
  95. *************
  96.      Clears the stack, rendering it empty.
  97.      Duplicates the value on the top of the stack, pushing another copy
  98.      of it.  Thus, `4d*p' computes 4 squared and prints it.
  99. File: dc.info,  Node: Registers,  Next: Parameters,  Prev: Stack Control,  Up: Top
  100. Registers
  101. *********
  102.    DC provides 128 memory registers, each named by a single ASCII
  103. character.  You can store a number in a register and retrieve it later.
  104.      Pop the value off the top of the stack and store it into register
  105.      R.
  106.      Copy the value in register R, and push it onto the stack.  This
  107.      does not alter the contents of R.
  108.      Each register also contains its own stack.  The current register
  109.      value is the top of the register's stack.
  110.      Pop the value off the top of the (main) stack and push it onto the
  111.      stack of register R.  The previous value of the register becomes
  112.      inaccessible.
  113.      Pop the value off the top of register R's stack and push it onto
  114.      the main stack.  The previous value in register R's stack, if any,
  115.      is now accessible via the `lR' command.
  116.    The `f' command prints a list of all registers that have contents
  117. stored in them, together with their contents.  Only the current
  118. contents of each register (the top of its stack) is printed.
  119. File: dc.info,  Node: Parameters,  Next: Strings,  Prev: Registers,  Up: Top
  120. Parameters
  121. **********
  122.    DC has three parameters that control its operation: the precision,
  123. the input radix, and the output radix.  The precision specifies the
  124. number of fraction digits to keep in the result of most arithmetic
  125. operations.  The input radix controls the interpretation of numbers
  126. typed in; *all* numbers typed in use this radix.  The output radix is
  127. used for printing numbers.
  128.    The input and output radices are separate parameters; you can make
  129. them unequal, which can be useful or confusing.  Each radix must be
  130. between 2 and 36 inclusive.  The precision must be zero or greater.
  131. The precision is always measured in decimal digits, regardless of the
  132. current input or output radix.
  133.      Pops the value off the top of the stack and uses it to set the
  134.      input radix.
  135.      Similarly set the output radix and the precision.
  136.      Pushes the current input radix on the stack.
  137.      Similarly push the current output radix and the current precision.
  138. File: dc.info,  Node: Strings,  Next: Status Inquiry,  Prev: Parameters,  Up: Top
  139. Strings
  140. *******
  141.    DC can operate on strings as well as on numbers.  The only things you
  142. can do with strings are print them and execute them as macros (which
  143. means that the contents of the string are processed as DC commands).
  144. Both registers and the stack can hold strings, and DC always knows
  145. whether any given object is a string or a number.  Some commands such as
  146. arithmetic operations demand numbers as arguments and print errors if
  147. given strings.  Other commands can accept either a number or a string;
  148. for example, the `p' command can accept either and prints the object
  149. according to its type.
  150. `[CHARACTE