TYPERULES Type Rules for Operators

Section: Mathematical Operators

Usage

Starting with FreeMat 4.0, the type of y is determined according to the same rules as Matlab. These are the rules:
  1. Integer types of the same class can be combined. The answer is the same type as the inputs, and the operation is performed using saturating arithmetic. Integer types can also be combined with double precision values (again, the result is of the integer type).
  2. Single precision floating point values can be combined with double precision, logical and character array classes. The result is of class single.
  3. Double precision floating point values can be combined with all other types. Except as noted above, the output is of double precision.
These rules look strange, and they are. In general, computations are done in double precision in almost all cases. When single precision values are involved, the computations take place in single precision.