## TYPERULES Type Rules

Section: FreeMat Functions

### Usage

FreeMat follows an extended form of C's type rules (the extension is to handle complex data types. The general rules are as follows:

- Integer types are promoted to `int32` types, except for matrix operations and division operations.
- Mixtures of `float` and `complex` types produce `complex` outputs.
- Mixtures of `double` or `int32` types and `dcomplex` types produce `dcomplex` outputs.
- Arguments to operators are promoted to the largest type present among the operands.
- Type promotion is not allowed to reduce the information content of the variable. The only exception to this is 64-bit integers, which can lose information when they are promoted to 64-bit `double` values.

These rules look tricky, but in reality, they are designed so that you do not actively have to worry about the types when performing mathematical operations in FreeMat. The flip side of this, of course is that unlike C, the output of numerical operations is not automatically typecast to the type of the variable you assign the value to.