| ▲ | Cold_Miserable 2 hours ago | |
I've yet to encounter a need for == equality for floating point operations. | ||
| ▲ | spacechild1 44 minutes ago | parent [-] | |
I need it all the time. A very common case is caching of (expensive) computations. Let's say you have a parameter for an audio plugin and every parameter change requires some non-trivial and possibly expensive computation (e.g. calculation of filter coefficients). To avoid wasting CPU cycles on every audio sample, you only do the (re)calculation when the parameter has actually changed:
Also, keep in mind that certain languages, such as JS, store all numbers as double-precision floating point numbers. So every time you are writing a numeric for-loop in JS you are implicitly relying on floating point equality :) | ||