1 :Info: calc:  2022-04-28  calc
  2 
  3 Syntax as a command:  calc {EXPRESSION}
  4 
  5 
  6 Syntax as an active function:  [calc EXPRESSION]
  7 
  8 
  9 Function: provides a calculator capable of evaluating arithmetic
 10 expressions with operator precedence, a set of often-used functions,
 11 and a memory that is symbolically addressable (i.e., by identifier).
 12 
 13 Invoke the command or active function with an EXPRESSION argument to
 14 immediately evaluate that expression.
 15 
 16 Invoke the command without arguments to enter the calculator
 17 subsystem.  The user may enter EXPRESSION lines, assign EXPRESSIONs to
 18 VARIABLEs, list VARIABLEs, etc.  Enter a quit (q) request to exit the
 19 subsystem.
 20 
 21 
 22 Arguments:
 23 EXPRESSION
 24    an arithmetic expression to be evaluated.  If this argument is
 25    specified, the calc command prints its value and returns to
 26    command level.  The expression must be quoted if it contains
 27    spaces or other command language characters.  Variables are not
 28    allowed.
 29 
 30 
 31 Notes on expressions:
 32 Arithmetic expressions involve real values and the operands +, -, *,
 33 /, and ** (addition, subtraction, multiplication, division, and
 34 exponentiation).  Unary (or prefix) plus (+) or minus (-) operators
 35 are allowed.  Parentheses can be used, and blanks between operators
 36 and values are ignored.  Calc evaluates each expression according to
 37 rules of precedence and prints out the result.  The order of
 38 evaluation is as follows:
 39 
 40   expressions within parentheses
 41   function references
 42   prefix +, prefix -
 43   **
 44   *, /
 45   +, -
 46 
 47 
 48 For example, if you type
 49 
 50    2 + 3 * 4
 51 
 52 calc responds
 53 
 54    = 14
 55 
 56 Operations sharing the same precedence level are processed from left
 57 to right except for the prefix plus and minus, which are processed
 58 from right to left.  This means 2**3**4 is evaluated as (2**3)**4.
 59 
 60 
 61 Notes on numbers:
 62 Numbers may be entered as integers (123), or fixed point strings
 63 (1.23).  Numbers may include an E-format exponent (123e5, 1.23e+2,
 64 1.23e2, 1.23E2, or 1230E-1).
 65 
 66 Numbers may end with a radix indicator (477o) to enter non-decimal
 67 values in bases 2 through 16.  Base 15 and 16 numbers may not use an
 68 E-format exponent indicator since the "e" or "E" is interpreted as a
 69 digit in those numbering systems; use a "p" or "P" exponent indicator
 70 instead (159p+5x).  See "List of radix indicators" below.
 71 
 72 Numbers are stored as float dec(59) values.  A precision of 59 decimal
 73 digits is maintained.  Exponent range: -128 <= EXPONENT <= +127
 74 
 75 
 76 List of requests:
 77    In the calculator subsystem, the following requests may be used.
 78 <EXPRESSION>
 79    prints out the value of expression.
 80 <VARIABLE>=<EXPRESSION>
 81    assigns value of expression to variable.
 82 list
 83    prints out the names and values of all the variables that have
 84    been declared so far.
 85 <VARIABLE>
 86    prints out the name and value of variable.
 87 q
 88    returns to command level.
 89 
 90 
 91 .
 92    causes calc to identify itself by printing "calc VERSION" where
 93    VERSION is the current version number of the calc subsystem.
 94 ..<COMMAND_LINE>
 95    causes the remainder of the line to be passed to Multics as a
 96    command line and executed.
 97 db_on
 98    sets an internal static flag enabling display of calc's push-down
 99    stack contents as expressions are evaluated.  Such display persists
100    for future invocations of calc in the process until db_off is
101    given.
102 db_off
103    disables display of calc's push-down stack contents as expressions
104    are evaluated.
105 
106 
107 Notes on assignment statements:
108 In the calculator subsystem, the value of an expression can be
109 assigned to a variable.  The form of an assisgnment is:
110 
111      <VARIABLE> = <EXPRESSION>
112 
113 The VARIABLE name must begin with a letter, have a total length
114 of 8 or fewer characters, and must be made up of uppercase and/or
115 lowercase letters, digits, and the underscore character (_).
116 
117 
118 For example, the following are legal assignment statements--
119 
120      x = 35
121 
122      Rho = sin(2*theta)
123 
124 The calc command does not print any response for an assignment
125 statement.
126 
127 
128 Notes on variables:
129 Variables can be used in place of literal numbers.  For example:
130 
131     r = 32
132     pi * r ** 2
133 
134 Preset variables include:
135     pi:   ratio of a circle's circumference to its diameter; and
136      e:   Euler's number
137 The first 59 digits of these irrational values have been stored.
138 
139 
140 List of functions:
141    Functions can be nested to any level.  For example:
142       sin(log(var)+.5*pi/2)
143 sin
144    sine(x) where x is in radians.
145 sind
146    sine(x) where x is in degrees.
147 cos
148    cosine(x) where x is in radians.
149 cosd
150    cosine(x) where x is in degrees.
151 tan
152    tangent(x) where x is in radians.
153 tand
154    tangent(x) where x is in degrees.
155 
156 
157 atan
158    arctan(x) in radians where: -pi/2 < arctan(x) < pi/2
159 atand
160    arctan(x) in degrees where: -90 < arctan(x) < 90
161 abs
162    if x > 0, result is x; otherwise, result is -x.
163 log, ln
164    log base e of x, also called ln(x) or the natural logarithm of x.
165 log10
166    log base 10 of x.
167 log2
168    log base 2 of x.
169 
170 
171 List of radix indicators:
172    Indicator characters may also be given in uppercase.
173 b, _b
174    the number is interpreted as a base two number (binary).
175    See "Notes" below.
176 q, _q
177    the number is interpreted as a base four number (quaternary).
178 o, _o
179    the number is interpreted as a base eight number (octal).
180 d, _d
181    the number is interpreted as a base ten number (decimal).
182    See "Notes" below.
183 x, _x
184    the number is interpreted as a base sixteen number (hexadecimal).
185 
186 
187 rN, _rN
188    the number is interpreted in the base N which is a decimal number
189    between 2 and 16 inclusive
190 
191 
192 :hcom:
193 /****^  HISTORY COMMENTS:
194   1) change(2021-12-05,GDixon), approve(2022-07-13,MCR10101),
195      audit(2022-07-27,Swenson):
196      Include calc 2.0 code enhancements, including a change from float bin(27)
197      to float dec(59) arithmetic; and support for non-decimal numbers.
198   2) change(2022-04-28,GDixon), approve(2022-07-13,MCR10101),
199      audit(2022-07-27,Swenson):
200      Add db_on and db_off requests to support display of calc's
201      push-down stack when debugging an input EXPRESSION.
202   3) change(2022-05-01,GDixon), approve(2022-07-13,MCR10101),
203      audit(2022-07-27,Swenson):
204       A) Document new functions added to calc: sind, cosd, tand, atand.
205       B) Document change in names of log functions to match PL/I function
206          names.
207             FUNCTION     calc 1.1 NAME      calc 2.0 NAME
208          --------------  ---------------    --------------------
209          log base e (x)      ln (x)          log  (x)  or  ln(x)
210          log base 10(x)      log(x)               log10(x)
211          log base 2 (x)   (not provided)     log2 (x)
212                                                    END HISTORY COMMENTS */
213