The __fp16
floating point data-type is a well known extension to the C standard used notably on ARM processors. I would like to run the IEEE version of them on my x86_64 processor. While I know they typically do not have that, I would be fine with emulating them with "unsigned short" storage (they have the same alignment requirement and storage space), and (hardware) float arithmetic.
Is there a way to request that in gcc?
I assume the rounding might be slightly "incorrect", but that is ok to me.
If this were to work in C++ too that would be ideal.
C++23 introduces std::float16_t
#include <stdfloat> // C++23
#if __STDCPP_FLOAT16_T__ != 1
#error "16-bit float type required"
#endif
int main()
{
std::float16_t f = 0.1F16;
}