IEEE 754 Floating Point Type in C++
kkimdev.github.io
kkimdev.github.io
All other things being equal, I guess it's a plus to conform to the letter of the standard, except they are not.
It's much more productive to pick a few practical compilers/architectures as your target and allow yourself to work within the assumptions they provide you.
I'm sure some people will disagree but I'd much rather enable no-strict-aliasing and be on my way than trying to figure out if I actually abide by the convoluted standard rule, since, after all, it does not mandate the existence of this option.
Relevant Linus Torvalds quote:
"There are competent people on standards bodies. But they aren't _always_ competent, and the translation of intent to English isn't always perfect either. So standards are not some kind of holy book that has to be revered. Standards too need to be questioned."
There are a lot of people that try. The nasty issue I've seen with the C standard is that most things work even if you bend the rules, until they suddenly don't and deviate in a weird way when you least expect it. Say you were porting software like this to a different compiler/architecture: how happy would you be to have to track down that floating point operations were broken because the author made assumptions about where the code would be running?
We need a maliciously compliant compiler (mcc) that does stuff like set float, double, and long double all to 32-bit.
Excessive template magic is just confusing. If you compile for a embedded platform there is a platform specific header anyway where you would put #define BIGGEST_FLOAT_TYPE double" or something.
(Entertainingly, all this template machinery doesn't seem to detect this issue, making it a bit of a waste of time)
[1] https://www.gnu.org/software/libc/manual/html_node/Reserved-...
/checks the spec
Hmm, a type that might be like double or might be like long double or might be implementation defined, depending on a "FLT_EVAL_METHOD", knowing that double and long double still are also implementation defined
What problem does double_t even solve then?
My point is, if IEEE 754 is a problem, you probably need to check things yourself anyway and can't trust whoever wrote numerical_limits at the chip manufacturer and that it applies to your platform without e.g. adding interrupt handlers etc. So you can't trust this template anyways.
You know what's fucked up? To the best of the knowledge you can't get the official IEEE 754 spec without paying a decent amount of money.
Why do we support the IEEE when pulling this kind of crap? Tons of standards are open! Like WHATWG, W3C, and IETF. Am I unreasonable for expecting standards documents to be free and open? I'm not an implementer, but being able to reference the spec is incredibly valuable in identifying what kind of behavior I can reasonably expect when developing something. If I'm researching something in a professional setting I can get my job to pay for it, but I don't really wanna pay for specs when I'm just poking around for fun.
Having a paywall behind specs also makes them nigh inaccessible for people from less privileged countries. There's no way a kid from, say, India or Latin America would be able to afford tons of these specs.
I'm certainly not an expert on the subject, but couldn't someone create an open "fork" of the IEEE 754 spec and have people refer to that instead?
Yes the draft versions are available, but you cannot be 100% sure that the final one isn't changed.
I actually think it's quite an ingenious mechanism for making money from the people who have it while not hindering the people who don't.
[1]: http://standards.iso.org/ittf/PubliclyAvailableStandards/
Then you don't, and just search the Internet harder. ;-)
Having a paywall behind specs also makes them nigh inaccessible for people from less privileged countries. There's no way a kid from, say, India or Latin America would be able to afford tons of these specs.
They all use SciHub, LibgeN, and the like.
> In short, the only machine the author could find using non-two’s complement are made by Unisys. Nowadays they emulate their old architecture using x86 CPUs for customers who have legacy applications which they’ve been unable to migrate.
- http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p090...
You would have to catch FPU interrupts and do the overflow/underflow/whatever yourself. So using this project would just lead to false positives.
it does. It checks for iec559 support which implies nan / inf / denormal support.
Now I totally agree that people should almost always not be storing these things on disk or passing them across the network, but they were RECOMMENDED by the IEEE committee, and that's why Intel and Motorola implemented them. A kinda bad idea, bad implementation choices, but recommended.
It's just too much effort to code to the actual standard and not worth it when essentially all computers use the same sizes and implementations of types.