11.2 Data Types

All 12 of the primary fixed-point types and their aliases, described in section 4.1 “Overview and principles of the fixed-point data types” of N1169, are supported via three fixed point formats corresponding to the intrinsic hardware capabilities of Microchip 16-bit devices.

Table 11-1. Fixed Point Formats - 16-bit Devices
FormatDescription
1.151 bit sign, 15 bits fraction
1.311 bit sign, 31 bits fraction
9.319 bit signed integer, 31 bits fraction

These formats represent the fixed-point C data types, shown below.

Table 11-2. Fixed Point Formats - C Data Types
TypeFormat
_Fract1.15
short _Fract1.15
signed _Fract1.15
signed short _Fract1.15
unsigned _Fract1.15 (sign bit 0)
unsigned short _Fract1.15 (sign bit 0)
long _Fract1.31
signed long _Fract1.31
unsigned long _Fract1.31 (sign bit 0)
_Accum9.31
short _Accum9.31
long _Accum9.31
signed _Accum9.31
signed short _Accum9.31
signed long _Accum9.31
unsigned _Accum9.31 (sign bit 0)
unsigned short _Accum9.31 (sign bit 0)
unsigned long _Accum9.31 (sign bit 0)

The _Sat type specifier, indicating that the values are saturated, may be used with any type as described in N1169.

Unsigned types are represented identically to signed types, but negative numbers (sign bit 1) are not valid values in the unsigned types. Signed types saturate at the most negative and positive numbers representable in the underlying format. Unsigned types saturate at 0 and the most positive number representable in the format.

The default behavior of overflow on signed or unsigned types is not saturation (as defined by the pragmas described in section 4.1.3 “Rounding and Overflow” of N1169). Therefore variables in signed or unsigned types that are not declared as saturating with the _Sat specifier may receive invalid values when assigned the result of an expression in which an overflow may occur (the results of non-saturating overflows are not defined.)