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

  1. .th BC I 2/20/75
  2. .sh NAME
  3. bc \*- arbitrary precision interactive language
  4. .sh SYNOPSIS
  5. .bd bc
  6. [
  7. .bd \-l
  8. ] [ file ... ]
  9. .sh DESCRIPTION
  10. .it Bc
  11. is an interactive processor for a language which resembles
  12. C but provides unlimited precision arithmetic.
  13. It takes input from any files given, then reads
  14. the standard input.
  15. The `\-l' argument stands for the name
  16. of a library of mathematical subroutines
  17. which contains sine (named `s'), cosine (`c'),
  18. arctangent (`a'), natural logarithm (`l'),
  19. and exponential (`e').
  20. The syntax for 
  21. .it bc
  22. programs is as follows;
  23. E means expression, S means statement.
  24. .s3
  25. .lp +6 6
  26. Comments
  27. .br
  28. are enclosed in /* and */.
  29. .s3
  30. .lp +6 6
  31. Names
  32. .br
  33. letters a\-z
  34. .br
  35. array elements: letter[E]
  36. .br
  37. The words `ibase', `obase', and `scale'
  38. .s3
  39. .lp +6 6
  40. Other operands
  41. .br
  42. arbitrarily long numbers with optional sign and decimal point.
  43. .br
  44. ( E )
  45. .br
  46. sqrt ( E )
  47. .br
  48. <letter> ( E , ... , E )
  49. .s3
  50. .lp +6 6
  51. Operators
  52. .br
  53. +  \-  *  /  %  ^
  54. .br
  55. ++   \-\-         (prefix and postfix; apply to names)
  56. .br
  57. ==  <=  >=  !=  <  >
  58. .br
  59. =  =+  =\-  =*  =/  =%  =^
  60. .br
  61. .s3
  62. .lp +6 6
  63. Statements
  64. .br
  65. E
  66. .br
  67. { S ; ... ; S }
  68. .br
  69. if ( E ) S
  70. .br
  71. while ( E ) S
  72. .br
  73. for ( E ; E ; E ) S
  74. .br
  75. null statement
  76. .br
  77. break
  78. .br
  79. quit
  80. .s3
  81. .lp +6 6
  82. Function definitions are exemplified by
  83. .br
  84. define <letter> ( <letter> ,..., <letter> ) {
  85. .br
  86.     auto <letter>, ... , <letter>
  87. .br
  88.     S; ... S
  89. .br
  90.     return ( E )
  91. .br
  92. }
  93. .s3
  94. .i0
  95. .dt
  96. All function arguments are passed by value.
  97. .s3
  98. The value of a statement that is an expression is printed
  99. unless the main operator is an assignment.
  100. Either semicolons or newlines may separate statements.
  101. Assignment to
  102. .it scale
  103. influences the number of digits to be retained on arithmetic
  104. operations.
  105. Assignments to
  106. .it ibase
  107. or
  108. .it obase
  109. set the input and output number radix respectively.
  110. .s3
  111. The same letter may be used as an array name, a function name,
  112. and a simple variable simultaneously.
  113. `Auto' variables are saved and restored during function calls.
  114. All other variables are global to the program.
  115. When using arrays as function arguments
  116. or defining them as automatic variables
  117. empty square brackets must follow the array name.
  118. .s3
  119. For example
  120. .s3
  121. .nf
  122. scale = 20
  123. define e(x){
  124.     auto a, b, c, i, s
  125.     a = 1
  126.     b = 1
  127.     s = 1
  128.     for(i=1; 1==1; i++){
  129.         a = a*x
  130.         b = b*i
  131.         c = a/b
  132.         if(c == 0) return(s)
  133.         s = s+c
  134.     }
  135. }
  136. .s3
  137. .fi
  138. defines a function to compute an approximate value of
  139. the exponential function and
  140. .s3
  141. .nf
  142.     for(i=1; i<=10; i++) e(i)
  143. .fi
  144. .s3
  145. prints approximate values of the exponential function of
  146. the first ten integers.
  147. .sh FILES
  148. /usr/lib/lib.b    mathematical library
  149. .sh "SEE ALSO"
  150. .it dc
  151. (I),
  152. C Reference Manual,
  153. ``BC \- An Arbitrary Precision Desk-Calculator Language.''
  154. .sh BUGS
  155. No &&, | | yet.
  156. .br
  157. .it for
  158. statement must have all three E's
  159. .br
  160. .it quit
  161. is interpreted when read, not when executed.
  162.