EGL Reference Guide for iSeries

Numeric expressions

A numeric expression resolves to a number, and you specify such an expression in various situations; for example, on the right side of an assignment statement. A numeric expression may be composed of any of these:

You may use paired parentheses in a numeric expression to change the order of evaluation or to clarify your meaning.

In reviewing the examples that follow, assume that intValue1 equals 1, intValue2 equals 2, and so on, and that each value has no decimal places:

  /* = -8, with the parentheses overriding 
           the usual precedence of * and + */
  intValue2 * (intValue1 - 5)
 
  /* = -2, with a unary minus as the last operator */ 
  intValue2 + -4 
 
  /* = 1.4, if the expression is assigned to an 
            item with at least one decimal place.  */
  intValue7 / intValue5
 
  /* = 2, which is a remainder 
          expressed as an integer value */
  intValue7 % intValue5

For COBOL output, a numeric expression may give an unexpected result if an intermediate, calculated value has more than 30 or 31 digits; the exact number of digits depends on the ARITH compiler option.

For Java output, a numeric expression may give an unexpected result if an intermediate, calculated value requires more than 128 bits.


Related reference
Items
Expressions
Logical expressions
Operators and precedence
Primitive types
String expressions


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]