Many of the intrinsic functions use fractional arithmetic with implied fractional values. An implied fractional value is a symbol declared as an integer type, but calculated as a fractional type. Data in a memory location or register can be interpreted as fractional or integer, depending on program needs.
All intrinsic functions that generate multiply or divide instructions perform fractional arithmetic on implied fractional values. (These intrinsic functions are DIV, MPY, MAC, MPYR, and MACR) The relationship between a 16-bit integer and a fractional value is:
Fractional Value = Integer Value / (215)
The relationship between a 32-bit integer and a fractional value is similar:
Fractional Value = Long Integer Value / (231)
The following table shows how 16- and 32-bit values can be interpreted as either fractional or integer values.
| Type | Hex | Integer Value | Fixed-Point Value |
|---|---|---|---|
| short int | 0x2000 | 8192 | 0.25 |
| short int | 0xE000 | -8192 | -0.25 |
| long int | 0x20000000 | 536870912 | 0.25 |
| long int | 0xE0000000 | -536870912 | -0.25 |