3.5. Fixed-Point Arithmetic
Prev | Chapter 3. Sourcery CodeBench Lite for ARM EABI | Next

## 3.5. Fixed-Point Arithmetic

Sourcery CodeBench for ARM EABI includes experimental support for fixed-point arithmetic using a set of new data types, as described in the draft ISO/IEC technical report TR 18037. This support is provided for all ARM targets, and uses specialized instructions where available, e.g. saturating add and subtract operations on ARMv6T2 and above. Library functions are used for operations which are not natively supported on the target architecture.

This feature is a GNU extension, so is only available when the selected language standard includes GNU extensions (e.g. `-std=gnu90`, which is the default). Furthermore, only C is supported, not C++.

TR 18037 leaves up to the implementation the sizes of various quantities within the new data types it defines. For Sourcery CodeBench for ARM EABI, these are, briefly:

- `short _Fract`: One sign bit, 7 fractional bits
- `_Fract`: One sign bit, 15 fractional bits
- `long _Fract`: One sign bit, 31 fractional bits
- `unsigned short _Fract`: 8 fractional bits
- `unsigned _Fract`: 16 fractional bits
- `unsigned long _Fract`: 32 fractional bits
- `short _Accum`: One sign bit, 7 fractional bits, 8 integral bits
- `_Accum`: One sign bit, 15 fractional bits, 16 integral bits
- `long _Accum`: One sign bit, 31 fractional bits, 32 integral bits
- `unsigned short _Accum`: 8 fractional bits, 8 integral bits
- `unsigned _Accum`: 16 fractional bits, 16 integral bits
- `unsigned long _Accum`: 32 fractional bits, 32 integral bits

These values (and various other useful constants) are also defined in the header file `stdfix.h` for use in your programs. Note that there is currently no support for the new standard-library functions described in TR 18037, nor for the pragmas controlling precision of operations.

Fixed-point extensions are not currently supported by GDB, nor are they compliant with the ARM EABI (which does not specify anything about fixed-point types at present). Code using fixed-point types cannot be expected to interact properly (across ABI boundaries) with code generated by other compilers for the ARM architecture.

Prev | Up | Next
3.4. Using VFP Floating Point | Home | 3.6. ABI Compatibility