3 ms·
Sorry, I should've been more clear. They are well defined and useful in a huge domain of applications, especially in those areas where an approximation is perfe
by stingraycharles 13y ago
Sorry, I should've been more clear. They are well defined and useful in a huge domain of applications, especially in those areas where an approximation is perfectly fine. For representing money, however, you need to be very, very careful and be aware of the many subtle bugs that can be introduced when using floats.
Also, that something is "well-defined" does not imply that is it not a mess. There are quite a few well-defined standards out there that clearly are a mess.
- reikonomusha 13y agoYou are right. For money, floating point computations are entirely inappropriate, but not because floating point is (supposedly) a "mess", but because floating point sacrifices uniform quantization for an exponential range of representable values. The IEEE-754 standard is not a mess. It is complicated, because it has to be. Extreme care and precision must be taken when talking about mathematical quantities which are neither closed nor associative under the provided operations. I challenge anyone else to make a concrete standard which supports accurate transcendental operations with numbers which range from 0 to 10^300 while remaining simple and easy to understand.
- nolite 13y agodid you not read the parent threads?
- reikonomusha 13y agoYes, I read them. And I am hearing that floats are "inaccurate", "a mess", and so on. I am not advocating their use to represent currency whatsoever, but the reasons are not because of the above, but rather the reason that I described.