3 ms·
The only implementation of IEEE754 decimals I've ever seen is in Python's Decimal package. Is there an easily-available implementation anywhere else?
by jordigh 4y ago
The only implementation of IEEE754 decimals I've ever seen is in Python's Decimal package. Is there an easily-available implementation anywhere else?
- zokier 4y agoI don't think Pythons Decimal is ieee754, instead its some sort of arbitrary precision thingy. GCC has builtin support for decimal floats: https://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html https://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html There are also library implementations floating around, some of them are mentioned in this thread: https://discourse.llvm.org/t/rfc-decimal-floating-point-support-iso-iec-ts-18661-2-and-c23/62152 https://discourse.llvm.org/t/rfc-decimal-floating-point-supp... decnumber has also rust wrappers if you are so inclined
- jordigh 4y agoPython's decimal absolutely is IEEE 754 (well, based on the older standard, which has now been absorbed into IEEE 754): https://github.com/python/cpython/blob/main/Lib/_pydecimal.py#L16 https://github.com/python/cpython/blob/main/Lib/_pydecimal.p... Cool, didn't know that gcc had built-in support. But is it really as incomplete as it says there?
- zokier 4y agoHuh, I didn't know it was that close, I'll grant that. But I'd say still no cigar. One of the most elementary requirements of IEEE754 is: > A programming environment conforms to this standard, in a particular radix, by implementing one or more of the basic formats of that radix as both a supported arithmetic format and a supported interchange format. (Section 3.1.2) While you could argue that you may configure Decimals context parameters to match those of some IEEE754 format and thus claim conformance as arithmetic format, Python has absolutely no support for the specified interchange formats. To be honest, seeing this I'm bit befuddled on why closer conformance with IEEE754 is not sought. Quick search found e.g. this issue report on adding IEEE754 parametrized context, which is a trivial patch, and it has been just sitting there for 10 years: https://github.com/python/cpython/issues/53032 https://github.com/python/cpython/issues/53032 Adding code to import/export BID/DPD formats, while maybe not as trivial, seems still comparatively small task and would improve interoperability significantly imho.