3 ms·
This is a recurring problem when working with floating point values. Intuitions about concepts like associativity or even equality don't necessarily hold, but i
by Silhouette 7y ago
This is a recurring problem when working with floating point values. Intuitions about concepts like associativity or even equality don't necessarily hold, but in many cases you will still get away with it, so it can feel like there's inconsistent or unpredictable behaviour. That can be a big stumbling block for inexperienced programmers working with this type of data at first, and it surely leads to many bugs.
With experience, programmers adjust their intuitive expectations and guarding against these kinds of bugs becomes second nature, and to some extent that is probably the best we can do because of the nature of the beast. However, it does illustrate the cost of violating intuitive expectations about how familiar operators and functions will behave.