Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is FLT_RADIX ever not 2 in C11 for modern general purpose computers?

That's pretty much my question in the title. It seems totally unnatural for anything else to be used.

In researching this I found that there are historical examples of hardware support for base 10, as well as the more modern examples of IBM POWER6 and system z9. Even in these cases, I do not know if FLT_RADIX would be 10 on any mainstream C compilers.

My particular concern is that I am writing code for an application that will only ever be ran on general purpose computers, and I would like to know if I can statically assert FLT_RADIX==2 without serious concern, like how I am currently statically asserting !(unsigned char)256.

like image 826
Jack Avatar asked Mar 20 '15 19:03

Jack


1 Answers

Annex F, an "optional" part of the C standard that's non-optional for any serious implementation where floating point will be used, requires IEEE single and double precision (binary32 and binary64) for float and double, respectively, so FLT_RADIX should always be 2. On systems where new decimal float stuff is supported, it's a separate extended type; FLT_RADIX==10 is not used for it.

like image 184
R.. GitHub STOP HELPING ICE Avatar answered Nov 01 '22 23:11

R.. GitHub STOP HELPING ICE