next up previous contents
Next: Mixed-Type Assignement Up: Mixing Types Previous: Mixing Types   Contents

Mixed-Type Expressions

Operations in ALU take place between operands of the same type. When mixed type operands appear in the same expression, it is up to the compiler to convert them to the proper, common type.

Default types obey the ordering


In a mixed expression the weaker type operands are promoted to the stronger type; the result is of the stronger type.

For example, the mixed-type expression

{}
i*r*dp*c
is evaluated left-to right (all have the same precedence). For the first the integer i is converted to real, and the result i*r is real; this result is then converted to double precision, and (i*r)*dp is a double precision result; finally, this result in its turn is converted to complex to be able to calculate ((i*r)*dp)*c; the returned result is complex.



Adrian Sandu 2001-08-26