Mixed Mode Arithmetic Expressions


If operands in an expression contains both INTEGER and REAL constants or variables, this is a mixed mode arithmetic expression.

In mixed mode arithmetic expressions, INTEGER operands are always converted to REAL before carrying out any computations. As a result, the result of a mixed mode expression is of REAL type. The following is a table showing this fact.

Operator INTEGER REAL
INTEGER INTEGER REAL
REAL REAL REAL

The rules for evaluating mixed mode arithmetic expressions are simple:

Simple Examples:

An Important Note:

In expression a**b where a is REAL, the result is undefined if the value of a is negative. For example, -4.0**2 is defined with -16.0 as its result, while (-4.0)**2 is undefined.

More Complicated Examples:

In the following, brackets will be used to indicated the order of evaluation and braces will be used to indicated an integer-to-real conversion. Click here to continue with single mode arithmetic expressions.