Character strings in NetRexx are commonly used for arithmetic (assuming, of course, that they represent numbers). The string representation of numbers can include integers, decimal notation, and exponential notation; they are all treated the same way. Here are a few:
'1234' '12.03' '-12' '120e+7'
The arithmetic operations in NetRexx are designed for people rather than machines, so are decimal rather than binary, do not overflow at certain values, and follow the rules that people use for arithmetic. The operations are completely defined by the ANSI standard for Rexx, so correct implementations will always give the same results.
An unusual feature of NetRexx arithmetic is the NUMERIC statement: this may be used to select the arbitrary precision of calculations. You may calculate to whatever precision that you wish, for financial calculations, perhaps, limited only by available memory. For example:
numeric digits 50 say 1/7
which would display
0.14285714285714285714285714285714285714285714285714
The numeric precision can be set for an entire program, or be adjusted at will within the program. The NUMERIC statement can also be used to select the notation (scientific_ or engineering_) used for numbers in exponential format.
NetRexx also provides simple access to the native binary arithmetic of computers. Using binary arithmetic offers many opportunities for errors, but is useful when performance is paramount. You select binary arithmetic by adding the statement:
options binary
at the top of a NetRexx program. The language processor will then use binary arithmetic instead of Rexx decimal arithmetic for calculations, throughout the program.
[ previous section | contents | next section ]
From 'nrover.doc', version 1.113.
Copyright(c) IBM Corporation, 1996, 1997. All rights reserved. ©