3 ms·
Fp arithmetic has brought down space ships. Is floating point a billion dollar mistake?
by syrrim 4y ago
Fp arithmetic has brought down space ships. Is floating point a billion dollar mistake?
- wizofaus 4y agoYou could reasonably argue that having languages make floating point arithmetic appear superficially similar to integer arithmetic despite key differences (inability to store exact results of various operations etc.) could qualify as such. In many ways it is surprising that more languages haven't been given features to help avoid FP- arithmetic/rounding/conversion/formatting issues - e.g. just adding a built-in decimal type can help a lot (it's woefully common to have decimal amounts such as monetary quantities stored as FP, particularly in Javascript).
- KMag 4y agoI've worked on international trading systems for a Fortune 500 broker-dealer that handled prices as IEEE-754 doubles, even though all currencies involved were decimalized. In the US, stock prices all have to be a multiple of $0.01, but in some markets, this minimum increment/decrement of a price ("tick size") is based on the price range, so lower priced stocks have finer-grained pricing. Determining if the customer was sending in a valid properly rounded price was a pain, as an upstream system had already parsed the price into a double and didn't pass our system the string representation.
- coldtea 4y agoFP is like a power saw tool you can use to cut wood or cut your fingers. null pointer is more like a safety belt silencer. Convenient, especially when you don't want to be bothered or listen to the warning "beep". But there's no actual healthy benefit from using it. That said, languages not providing a first class fast fixed precision/rational/decimal implementation for where precision is required, and this having been relegated to niche libs, is indeed a mistake.
- jjtheblunt 4y agowhen?