Mixed arithmetic

Up to now, the four basic arithmetic operators have always had operands of the same modes. In practice, it is quite surprising how often you want to compute something like 2 * 3.0. Well, fortunately, the dyadic operators +, -, * and / (but not %) are also defined for mixed modes. That is, any combination of REAL and INT can be used. With mixed modes the yield is always REAL. Thus the following formulæ are all valid:

   1+2.5    3.1*-4    2*3.5**3    2.4-2

The priority of the mixed-mode operators is unchanged. As we shall see later, the priority relates to the operator symbol rather than the flavour of the operator in use.


Sian Mountbatten 2012-01-19