home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man1 / dc.1 < prev    next >
Encoding:
Text File  |  1975-06-26  |  4.0 KB  |  182 lines

  1. .th DC I 2/8/75
  2. .sh NAME
  3. dc \*- desk calculator
  4. .sh SYNOPSIS
  5. .bd dc
  6. [ file ]
  7. .sh DESCRIPTION
  8. .it Dc
  9. is an arbitrary precision arithmetic package.
  10. Ordinarily it operates on decimal integers,
  11. but one may specify an input base, output base,
  12. and a number of fractional digits to be maintained.
  13. The overall structure of
  14. .it dc
  15. is
  16. a stacking (reverse Polish) calculator.
  17. If an argument is given,
  18. input is taken from that file until its end,
  19. then from the standard input.
  20. The following constructions are recognized:
  21. .s3
  22. .lp +6 6
  23. number
  24. .br
  25. The value of the number is pushed on the stack.
  26. A number is an unbroken string of the digits 0-9.
  27. It may be preceded by an underscore \*_ to input a
  28. negative number.
  29. Numbers may contain decimal points.
  30. .s3
  31. .lp +6 6
  32. +  \-  *  %  ^
  33. .br
  34. The
  35. top two values on the stack are added
  36. (+),
  37. subtracted
  38. (\*-),
  39. multiplied (*),
  40. divided (/),
  41. remaindered (%),
  42. or exponentiated (^).
  43. The two entries are popped off the stack;
  44. the result is pushed on the stack in their place.
  45. Any fractional part of an exponent is ignored.
  46. .s3
  47. .lp +6 6
  48. \fBs\fIx\fR    The
  49. top of the stack is popped and stored into
  50. a register named
  51. .it x,
  52. where
  53. .it x
  54. may be any character.
  55. If
  56. the
  57. .bd s
  58. is capitalized,
  59. .it x
  60. is treated as a stack and the value is pushed on it.
  61. .s3
  62. .lp +6 6
  63. \fBl\fIx\fR    The
  64. value in register
  65. .it x
  66. is pushed on the stack.
  67. The register
  68. .it x
  69. is not altered.
  70. All registers start with zero value.
  71. If the
  72. .bd l
  73. is capitalized,
  74. register
  75. .it x
  76. is treated as a stack and its top value is popped onto the main stack.
  77. .s3
  78. .lp +6 6
  79. \fBd\fR    The
  80. top value on the stack is duplicated.
  81. .s3
  82. .lp +6 6
  83. \fBp\fR    The top value on the stack is printed.
  84. The top value remains unchanged.
  85. .s3
  86. .lp +6 6
  87. \fBf\fR    All values on the stack and in registers are printed.
  88. .s3
  89. .lp +6 6
  90. \fBq\fR    exits the program.
  91. If executing a string, the recursion level is
  92. popped by two.
  93. If
  94. .bd q
  95. is capitalized,
  96. the top value on the stack is popped and the string execution level is popped
  97. by that value.
  98. .s3
  99. .lp +6 6
  100. \fBx\fR    treats the top element of the stack as a character string
  101. and executes it as a string of dc commands.
  102. .s3
  103. .lp +6 6
  104. \fB[ ... ]\fR    puts the bracketed ascii string onto the top of the stack.
  105. .s3
  106. .lp +6 6
  107. \fI<x  >x  =x\fR
  108. .br
  109. The
  110. top two elements of the stack are popped and compared.
  111. Register
  112. .it x
  113. is executed if they obey the stated
  114. relation.
  115. .s3
  116. .lp +6 6
  117. \fBv\fR    replaces the top element on the stack by its square root.
  118. Any existing fractional part of the argument is taken
  119. into account, but otherwise the scale factor is ignored.
  120. .s3
  121. .lp +6 6
  122. \fB!\fR    interprets the rest of the line as a UNIX command.
  123. .s3
  124. .lp +6 6
  125. \fBc\fR    All values on the stack are popped.
  126. .s3
  127. .lp +6 6
  128. \fBi\fR    The top value on the stack is popped and used as the
  129. number radix for further input.
  130. .s3
  131. .lp +6 6
  132. \fBo\fR    The top value on the stack is popped and used as the
  133. number radix for further output.
  134. .s3
  135. .lp +6 6
  136. \fBk\fR    the top of the stack is popped, and that value is used as
  137. a non-negative scale factor:
  138. the appropriate number of places
  139. are printed on output,
  140. and maintained during multiplication, division, and exponentiation.
  141. The interaction of scale factor,
  142. input base, and output base will be reasonable if all are changed
  143. together.
  144. .s3
  145. .lp +6 6
  146. \fBz\fR    The stack level is pushed onto the stack.
  147. .s3
  148. .lp +6 6
  149. \fB?\fR    A line of input is taken from the input source (usually the console)
  150. and executed.
  151. .s3
  152. .i0
  153. An example which prints the first ten values of n! is
  154. .nf
  155. .s3
  156. .in +3
  157. .bd "[la1+dsa*pla10>y]sy"
  158. .bd "0sa1"
  159. .bd lyx
  160. .i0
  161. .fi
  162. .sh "SEE ALSO"
  163. bc (I),
  164. which is a preprocessor for
  165. .it dc
  166. providing infix notation and a C-like syntax
  167. which implements functions and  reasonable control
  168. structures for programs.
  169. .sh DIAGNOSTICS
  170. (x) ? for unrecognized character x.
  171. .br
  172. (x) ? for not enough elements on the stack to do what was asked by command x.
  173. .br
  174. `Out of space' when the free list is exhausted (too many digits).
  175. .br
  176. `Out of headers' for too many numbers being kept around.
  177. .br
  178. `Out of pushdown' for too many items on the stack.
  179. .br
  180. `Nesting Depth' for too many levels of nested execution.
  181. .sh BUGS
  182.