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:
- A numeric operand, which is one of these:
- An item (or a system variable) that contains a number. The item may be preceded with a sign.
- A numeric literal, which may begin with a sign, but always has a series of digits and may include a single decimal point.
- A function invocation that returns a number. (You cannot reference a function in a logical expression, however.)
- A numeric operand, followed by a numeric operator, followed by a second numeric operand. (The operands cannot reference a function.)
- A more complex expression formed by using a numeric operator to combine a pair of more elementary expressions. (The expression cannot reference a function.)
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 % intValue5A numeric expression may give an unexpected result if an intermediate, calculated value requires more than 128 bits.
Related reference
Datetime expressions
Expressions
Items
Logical expressions
Operators and precedence
Primitive types
Text expressions