C /

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:

Typesizeofunsignedsigned
short10.8s0.7
-20.16s0.15
long40.32s0.31

_Accum sizes:

Typesizeofunsignedsigned
short28.8s8.7
-416.16s16.15
long832.32s32.31

Fixed Point Literal Suffixes:

TypeSuffix
short _Fracthr
unsigned short _Fractuhr
_Fractr
unsigned _Fractur
long _Fractlr
unsigned long _Fractulr
TypeSuffix
short _Accumhk
unsigned short _Accumuhk
_Accumk
unsigned _Accumuk
long _Accumlk
unsigned long _Accumulk