4 ms·
IMHO the biggest problem that developers run into is base 2's inability to represent decimal digits exactly. If floating-point numbers were stored (or behaved a
by winternewt 3y ago
IMHO the biggest problem that developers run into is base 2's inability to represent decimal digits exactly. If floating-point numbers were stored (or behaved as if stored) in base 10 then the other pitfalls would seem intuitive and predictable.
- gumby 3y agoIEEE-754 has supported base 10 FP but I haven’t seen any languages, or processors, that support it.
- versteegen 3y agoHere's one well known language: C23! (_Decimal32, _Decimal64, _Decimal128 [1].) Already supported by GCC [2]. Another language with support is .NET C# (System.Decimal) [3]. As for processors, according to Wikipedia [4], "IBM POWER6 and newer POWER processors include DFP in hardware, as does the IBM System z9 (and later zSeries machines). ... Fujitsu also has 64-bit Sparc processors with DFP in hardware." [1] https://en.cppreference.com/w/c/23 https://en.cppreference.com/w/c/23 [2] https://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html https://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html [3] https://learn.microsoft.com/en-us/dotnet/api/system.decimal?view=net-7.0 https://learn.microsoft.com/en-us/dotnet/api/system.decimal?... [4] https://en.wikipedia.org/wiki/Decimal_floating_point https://en.wikipedia.org/wiki/Decimal_floating_point
- gumby 3y agoWow, thanks! HN FTW again.