3 ms·
You could reasonably argue that having languages make floating point arithmetic appear superficially similar to integer arithmetic despite key differences (inab
by wizofaus 4y ago
You 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.