4 ms·
Whats wrong with "double_t"? Excessive template magic is just confusing. If you compile for a embedded platform there is a platform specific header anyway wher
by rightbyte 8y ago
Whats wrong with "double_t"?
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.
- Aardwolf 8y ago> Whats wrong with "double_t"? /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?
- rightbyte 8y agoIt's maybe the type with most precision according to whoever wrote the header at the chip manufacturer , so you can use it to do a calculation with hardware types with the least amount of error on the platform, maybe. 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.
- pjc50 8y agoFor a long time on the most popular platform, Intel 32-bit, double wasn't IEEE754 64-bit float by default. It was 80-bit internally, causing weird discrepancies. A description: https://stackoverflow.com/questions/3206101/extended-80-bit-double-floating-point-in-x87-not-sse2-we-dont-miss-it https://stackoverflow.com/questions/3206101/extended-80-bit-... (Entertainingly, all this template machinery doesn't seem to detect this issue, making it a bit of a waste of time)
- shaklee3 8y agoPretty sure that's still the case, right?
- simonbyrne 8y agoNot generally: most compilers make use of the SSE instruction set which doesn't have extended precision. Occasionally old versions of gcc on 32-bit machines will still use the old x87 instructions (which do have extended precision), but these are becoming increasingly rare in the wild.
- berti 8y agoA little tangential: POSIX reserves the suffix _t for itself [1]. [1] https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html https://www.gnu.org/software/libc/manual/html_node/Reserved-...