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 an example that shows the effect of parentheses on the use of a plus (+) sign, see Expressions.

A numeric expression may give an unexpected result if an intermediate, calculated value requires more than 128 bits.

Related reference
Datetime expressions
Expressions
Logical expressions
Operators and precedence
Primitive types
Text expressions

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.