next up previous contents
Next: Mixed Type Assignment Up: Mixing Objects of Different Previous: Mixing Objects of Different

Mixed Type Numeric Expressions

If an expression mixes type, the compiler must automatically convert (promote) one type to another. Default types have an implied ordering:

  1. INTEGER -- lowest
  2. REAL
  3. DOUBLE PRECISION
  4. COMPLEX -- highest

For example, if an INTEGER is mixed with a REAL the INTEGER is promoted to (represented as) a REAL and then the calculation performed.

Consider,

    int*real*dp*c

the types are coerced as follows: int to REAL int*real to DOUBLE PRECISION and (int*real)*dp to COMPLEX. The above expression is COMPLEX valued.

For more information, click here gif


next up previous contents
Next: Mixed Type Assignment Up: Mixing Objects of Different Previous: Mixing Objects of Different

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 18:56:08 GMT 1996
Not for commercial use.