home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / dc-0.2-src.lha / src / amiga / dc-0.2 / dc.info < prev    next >
Encoding:
GNU Info File  |  1993-04-18  |  10.9 KB  |  331 lines

  1. This is Info file dc.info, produced by Makeinfo-1.52 from the input
  2. file dc.texinfo.
  3.  
  4.    This file documents DC, an arbitrary precision calculator.
  5.  
  6.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  7. Cambridge, MA 02139 USA
  8.  
  9.    Copyright (C) 1984 Free Software Foundation, Inc.
  10.  
  11.    Permission is granted to make and distribute verbatim copies of this
  12. manual provided the copyright notice and this permission notice are
  13. preserved on all copies.
  14.  
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided that
  17. the entire resulting derived work is distributed under the terms of a
  18. permission notice identical to this one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that this permission notice may be stated in a
  23. translation approved by the Foundation.
  24.  
  25. 
  26. File: dc.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  27.  
  28. * Menu:
  29.  
  30. * Introduction::                Introduction
  31. * Printing Commands::           Printing Commands
  32. * Arithmetic::                  Arithmetic
  33. * Stack Control::               Stack Control
  34. * Registers::                   Registers
  35. * Parameters::                  Parameters
  36. * Strings::                     Strings
  37. * Status Inquiry::              Status Inquiry
  38. * Notes::                       Notes
  39.  
  40. 
  41. File: dc.info,  Node: Introduction,  Next: Printing Commands,  Prev: Top,  Up: Top
  42.  
  43. Introduction
  44. ************
  45.  
  46.    DC is a reverse-polish desk calculator which supports unlimited
  47. precision arithmetic.  It also allows you to define and call macros.
  48. Normally DC reads from the standard input; if any command arguments are
  49. given to it, they are filenames, and DC reads and executes the contents
  50. of the files before reading from standard input.  All output is to
  51. standard output.
  52.  
  53.    To exit, use `q'.  `C-c' does not exit; it is used to abort macros
  54. that are looping, etc.  (Currently this is not true; `C-c' does exit.)
  55.  
  56.    A reverse-polish calculator stores numbers on a stack.  Entering a
  57. number pushes it on the stack.  Arithmetic operations pop arguments off
  58. the stack and push the results.
  59.  
  60.    To enter a number in DC, type the digits, with an optional decimal
  61. point.  Exponential notation is not supported.  To enter a negative
  62. number, begin the number with `_'.  `-' cannot be used for this, as it
  63. is a binary operator for subtraction instead.  To enter two numbers in
  64. succession, separate them with spaces or newlines.  These have no
  65. meaning as commands.
  66.  
  67. 
  68. File: dc.info,  Node: Printing Commands,  Next: Arithmetic,  Prev: Introduction,  Up: Top
  69.  
  70. Printing Commands
  71. *****************
  72.  
  73. `p'
  74.      Prints the value on the top of the stack, without altering the
  75.      stack.  A newline is printed after the value.
  76.  
  77. `P'
  78.      Prints the value on the top of the stack, popping it off, and does
  79.      not print a newline after.
  80.  
  81. `f'
  82.      Prints the entire contents of the stack and the contents of all of
  83.      the registers, without altering anything.  This is a good command
  84.      to use if you are lost or want to figure out what the effect of
  85.      some command has been.
  86.  
  87. 
  88. File: dc.info,  Node: Arithmetic,  Next: Stack Control,  Prev: Printing Commands,  Up: Top
  89.  
  90. Arithmetic
  91. **********
  92.  
  93. `+'
  94.      Pops two values off the stack, adds them, and pushes the result.
  95.      The precision of the result is determined only by the values of
  96.      the arguments, and is enough to be exact.
  97.  
  98. `-'
  99.      Pops two values, subtracts the first one popped from the second
  100.      one popped, and pushes the result.
  101.  
  102. `*'
  103.      Pops two values, multiplies them, and pushes the result.  The
  104.      number of fraction digits in the result is controlled by the
  105.      current precision flag (see below) and does not depend on the
  106.      values being multiplied.
  107.  
  108. `/'
  109.      Pops two values, divides the second one popped from the first one
  110.      popped, and pushes the result.  The number of fraction digits is
  111.      specified by the precision flag.
  112.  
  113. `%'
  114.      Pops two values, computes the remainder of the division that the
  115.      `/' command would do, and pushes that.  The division is done with
  116.      as many fraction digits as the precision flag specifies, and the
  117.      remainder is also computed with that many fraction digits.
  118.  
  119. `^'
  120.      Pops two values and exponentiates, using the first value popped as
  121.      the exponent and the second popped as the base.  The fraction part
  122.      of the exponent is ignored.  The precision flag specifies the
  123.      number of fraction digits in the result.
  124.  
  125. `v'
  126.      Pops one value, computes its square root, and pushes that.  The
  127.      precision flag specifies the number of fraction digits in the
  128.      result.
  129.  
  130.    Most arithmetic operations are affected by the "precision flag",
  131. which you can set with the `k' command.  The default precision value is
  132. zero, which means that all arithmetic except for addition and
  133. subtraction produces integer results.
  134.  
  135.    The remainder operation (`%') requires some explanation: applied to
  136. arguments `a' and `b' it produces `a - (b * (a / b))', where `a / b' is
  137. computed in the current precision.
  138.  
  139. 
  140. File: dc.info,  Node: Stack Control,  Next: Registers,  Prev: Arithmetic,  Up: Top
  141.  
  142. Stack Control
  143. *************
  144.  
  145. `c'
  146.      Clears the stack, rendering it empty.
  147.  
  148. `d'
  149.      Duplicates the value on the top of the stack, pushing another copy
  150.      of it.  Thus, `4d*p' computes 4 squared and prints it.
  151.  
  152. 
  153. File: dc.info,  Node: Registers,  Next: Parameters,  Prev: Stack Control,  Up: Top
  154.  
  155. Registers
  156. *********
  157.  
  158.    DC provides 128 memory registers, each named by a single ASCII
  159. character.  You can store a number in a register and retrieve it later.
  160.  
  161. `sR'
  162.      Pop the value off the top of the stack and store it into register
  163.      R.
  164.  
  165. `lR'
  166.      Copy the value in register R, and push it onto the stack.  This
  167.      does not alter the contents of R.
  168.  
  169.      Each register also contains its own stack.  The current register
  170.      value is the top of the register's stack.
  171.  
  172. `SR'
  173.      Pop the value off the top of the (main) stack and push it onto the
  174.      stack of register R.  The previous value of the register becomes
  175.      inaccessible.
  176.  
  177. `LR'
  178.      Pop the value off the top of register R's stack and push it onto
  179.      the main stack.  The previous value in register R's stack, if any,
  180.      is now accessible via the `lR' command.
  181.  
  182.    The `f' command prints a list of all registers that have contents
  183. stored in them, together with their contents.  Only the current
  184. contents of each register (the top of its stack) is printed.
  185.  
  186. 
  187. File: dc.info,  Node: Parameters,  Next: Strings,  Prev: Registers,  Up: Top
  188.  
  189. Parameters
  190. **********
  191.  
  192.    DC has three parameters that control its operation: the precision,
  193. the input radix, and the output radix.  The precision specifies the
  194. number of fraction digits to keep in the result of most arithmetic
  195. operations.  The input radix controls the interpretation of numbers
  196. typed in; *all* numbers typed in use this radix.  The output radix is
  197. used for printing numbers.
  198.  
  199.    The input and output radices are separate parameters; you can make
  200. them unequal, which can be useful or confusing.  Each radix must be
  201. between 2 and 36 inclusive.  The precision must be zero or greater.
  202. The precision is always measured in decimal digits, regardless of the
  203. current input or output radix.
  204.  
  205. `i'
  206.      Pops the value off the top of the stack and uses it to set the
  207.      input radix.
  208.  
  209. `o'
  210. `k'
  211.      Similarly set the output radix and the precision.
  212.  
  213. `I'
  214.      Pushes the current input radix on the stack.
  215.  
  216. `O'
  217. `K'
  218.      Similarly push the current output radix and the current precision.
  219.  
  220. 
  221. File: dc.info,  Node: Strings,  Next: Status Inquiry,  Prev: Parameters,  Up: Top
  222.  
  223. Strings
  224. *******
  225.  
  226.    DC can operate on strings as well as on numbers.  The only things you
  227. can do with strings are print them and execute them as macros (which
  228. means that the contents of the string are processed as DC commands).
  229. Both registers and the stack can hold strings, and DC always knows
  230. whether any given object is a string or a number.  Some commands such as
  231. arithmetic operations demand numbers as arguments and print errors if
  232. given strings.  Other commands can accept either a number or a string;
  233. for example, the `p' command can accept either and prints the object
  234. according to its type.
  235.  
  236. `[CHARACTERS]'
  237.      Makes a string containing CHARACTERS and pushes it on the stack.
  238.      For example, `[foo]P' prints the characters `foo' (with no
  239.      newline).
  240.  
  241. `x'
  242.      Pops a value off the stack and executes it as a macro.  Normally
  243.      it should be a string; if it is a number, it is simply pushed back
  244.      onto the stack.  For example, `[1p]x' executes the macro `1p',
  245.      which pushes 1 on the stack and prints `1' on a separate line.
  246.  
  247.      Macros are most often stored in registers; `[1p]sa' stores a macro
  248.      to print `1' into register `a', and `lax' invokes the macro.
  249.  
  250. `>R'
  251.      Pops two values off the stack and compares them assuming they are
  252.      numbers, executing the contents of register R as a macro if the
  253.      original top-of-stack is greater.  Thus, `1 2>a' will invoke
  254.      register `a''s contents and `2 1>a' will not.
  255.  
  256. `<R'
  257.      Similar but invokes the macro if the original top-of-stack is less.
  258.  
  259. `=R'
  260.      Similar but invokes the macro if the two numbers popped are equal.
  261.      This can also be validly used to compare two strings for equality.
  262.  
  263. `?'
  264.      Reads a line from the terminal and executes it.  This command
  265.      allows a macro to request input from the user.
  266.  
  267. `q'
  268.      During the execution of a macro, this comand does not exit DC.
  269.      Instead, it exits from that macro and also from the macro which
  270.      invoked it (if any).
  271.  
  272. `Q'
  273.      Pops a value off the stack and uses it as a count of levels of
  274.      macro execution to be exited.  Thus, `3Q' exits three levels.
  275.  
  276. 
  277. File: dc.info,  Node: Status Inquiry,  Next: Notes,  Prev: Strings,  Up: Top
  278.  
  279. Status Inquiry
  280. **************
  281.  
  282. `Z'
  283.      Pops a value off the stack, calculates the number of digits it has
  284.      (or number of characters, if it is a string) and pushes that
  285.      number.
  286.  
  287. `X'
  288.      Pops a value off the stack, calculates the number of fraction
  289.      digits it has, and pushes that number.  For a string, the value
  290.      pushed is -1.
  291.  
  292. `z'
  293.      Pushes the current stack depth; the number of objects on the stack
  294.      before the execution of the `z' command.
  295.  
  296. `I'
  297.      Pushes the current value of the input radix.
  298.  
  299. `O'
  300.      Pushes the current value of the output radix.
  301.  
  302. `K'
  303.      Pushes the current value of the precision.
  304.  
  305. 
  306. File: dc.info,  Node: Notes,  Prev: Status Inquiry,  Up: Top
  307.  
  308. Notes
  309. *****
  310.  
  311.    The `:' and `;' commands of the Unix DC program are not supported,
  312. as the documentation does not say what they do.  The `!' command is not
  313. supported, but will be supported as soon as a library for executing a
  314. line as a command exists.
  315.  
  316.  
  317. 
  318. Tag Table:
  319. Node: Top960
  320. Node: Introduction1440
  321. Node: Printing Commands2603
  322. Node: Arithmetic3211
  323. Node: Stack Control5168
  324. Node: Registers5468
  325. Node: Parameters6586
  326. Node: Strings7659
  327. Node: Status Inquiry9857
  328. Node: Notes10571
  329. 
  330. End Tag Table
  331.