contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
Precedence of numeric operators
Prerequisite Concepts      

Operator precedence is the order in which operators are evaluated. When two operators apply to the same term, the one with the higher precedence is evaluated first.

Monadic operators are operators which only take a single operand. Dyadic take two operands. Monadic operators always have precedence over dyadic operators.

The precedence table for numeric operators from highest precedence to lowest is:

  1. All monadic operators such as: "+", "-", complement
  2. "*", "/", modulo, shift, and mask have the same precedence
  3. Dyadic "+", dyadic "-", difference, and union have the same precedence

Bit-oriented and arithmetic operators may be combined in numeric expressions. Parentheses can be used to group subexpressions to override the precedence, and leading minus signs can be parenthesized with their arguments as well.

This example illustrates the order of evaluation of numeric operators.

  11 mask 5 * 3 + 14 union 35 shift 5 / 56 + complement 3
is equivalent to:
  ((((11 mask 5) * 3) + 14) union ((35 shift 5) / 56)) + (complement 3)

This is evaluated as follows, starting with the innermost parentheses:

This example illustrates how parentheses can be used to override the precedence of numeric operators. The first example evaluates as 17, while the second evaluates to 21.

  3 * 5 + 2
  3 * (5 + 2)

Prerequisite Concepts
     Arithmetic and comparison operators
   Bit-oriented arithmetic
   Numeric expressions
 
   
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:00:50 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.