Additional Operator Examples

Following are some examples using the power, integer divide, and remainder operators:
/* Again with:  Numeric digits 5 */
2**3       ->     8
2**-3      ->     0.125
1.7**8     ->    69.758
2%3        ->     0
2.1//3     ->     2.1
10%3       ->     3
10//3      ->     1
-10//3     ->    -1
10.2//1    ->     0.2
10//0.3    ->     0.1
3.6//1.3   ->     1.0
Note:
  1. A particular algorithm for calculating powers is used, because it is efficient (though not optimal) and considerably reduces the number of actual multiplications performed. It, therefore, gives better performance than the simpler definition of repeated multiplication. Because results may differ from those of repeated multiplication, the algorithm is defined here.
  2. The integer divide and remainder operators are defined so that they can be calculated as a by-product of the standard division operation. The division process is ended as soon as the integer result is available; the residue of the dividend is the remainder.

Reference Reference

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/dfhrx00085.html