FixedPoint
Fixed Point support on C. Last time I checked it only worked on gcc on certain architectures. It worked on ARM, but not on RISC-V or x86-64. Clang didn't support it yet, but I've recently found clues clang might have gained support. https://libc.llvm.org/math/stdfix.html
While the gcc documentation mentions the data types, their width ain't clearly documented. https://gcc.gnu.org/wiki/FixedPointArithmetic https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/fixed-point-types.html The Fixed Point Documentation https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf leaves this implementation defined.
I have found some document on Microchip's website discussing the data types on the PIC32, which has a MIPS architecture. https://onlinedocs.microchip.com/oxy/GUID-471BA167-B55F-488B-A1CC-D88BAA7832CA-en-US-4/GUID-87C22A8E-88A5-4AFC-A0A5-CD2768DC8AC0.html Another list of fixed point types is in the avr-gcc documentation https://gcc.gnu.org/wiki/avr-gcc which appears to match. While the specs say it is implementation defined, this list may be the de-facto standard
_Fract sizes:
Type | sizeof | unsigned | signed |
short | 1 | 0.8 | s0.7 |
- | 2 | 0.16 | s0.15 |
long | 4 | 0.32 | s0.31 |
_Accum sizes:
Type | sizeof | unsigned | signed |
short | 2 | 8.8 | s8.7 |
- | 4 | 16.16 | s16.15 |
long | 8 | 32.32 | s32.31 |
Fixed Point Literal Suffixes:
Type | Suffix |
short _Fract | hr |
unsigned short _Fract | uhr |
_Fract | r |
unsigned _Fract | ur |
long _Fract | lr |
unsigned long _Fract | ulr |
Type | Suffix |
short _Accum | hk |
unsigned short _Accum | uhk |
_Accum | k |
unsigned _Accum | uk |
long _Accum | lk |
unsigned long _Accum | ulk |