Mixed Mode

Mixed Mode

Top  Previous  Next

XPL0 does not allow integer and real factors to be used directly together in the same expression. For instance:

 

        2 + 3.5

 

This causes a compile error. It should be changed to:

 

        2. + 3.5

 

To do calculations on a mixture of reals and integers, convert the factors to a single data type using the Fix and Float intrinsics. Fix changes reals to integers, and Float changes integers to reals. For example, if the variable X is a real and I is an integer then calculations are done as follows:

 

        Fix(X) + I

        X + Float(I)