NET/MASTER Network Control Language (NCL) Reference Manual
Arithmetic Operators and Expressions
Expressions and Operators
106126 Tandem Computers Incorporated 10–13
NCL supports numbers to 15 decimal digits of precision. NCL supports a range of
1e-50 through 1e+50. This is within the range supported by the operating system of
8.63616855509445e-78 (the absolute value of the smallest representable number)
through 1.15792089237161e77 (the absolute value of the largest representable number).
Some examples of arithmetic expressions are:
Expression Operation Result
1 + 2 Addition 3
497021 - 7832 Subtraction 489189
0.08 + 76.889 Addition 76.969
38 - 97 Subtraction -59
1e5 - 22.9 Subtraction 99977.1
10 - -10 Subtraction 20
2 ** 3 Exponentiation 8
44 / 11 Division 4
45 / 11 Division 4.090909…
45 // 11 Integer division 4
10 % 6 Remainder 4
A variable that contains a numeric value can represent a number; for example:
&A + 1
&COUNTER + &INCREMENT
Precision of Numbers
Loss of precision can occur when dealing with values that are very small or very large,
relative to each other. The following example, which performs an operation that relies
on operand ordering for correct execution, illustrates this.
Assume, using three digits of precision, that you want the result of the expression
.990e50 - &a + .002e49 in which &a is between .900e50 and .990e50. During
compilation, the compiler rearranges the expression to be (.990e50 + .002e49) - &a,
giving the result .990e50 - &a. This may not give the result you expect from the
original expression. For example, if &a is .900e50, the result is .900e49.
To force the evaluation order that you require, you must use parentheses as shown
next. The following example gives the result .902e49 when &a equals .900e50.
(.990e50 - &a) + .002e49
You can use the ON statement with either the general ERROR handler or the specific
ARITH_ERROR handler to trap numbers that do not fall within the range of numbers
accepted by NCL.