3 ms·
FLT_EPSILON is the difference between 1.0f and the next float. With that we can work out the math: - If you add 1.0f to FLT_EPSILON then you get an exact resul
by brucedawson 6y ago
FLT_EPSILON is the difference between 1.0f and the next float. With that we can work out the math:
- If you add 1.0f to FLT_EPSILON then you get an exact result
- If you add 1.0f to FLT_EPSILON * 0.5 then you get a number that cannot be represented and it will either round to 1.0 or 1.0+FLT_EPSILON
- Similarly, if you add 0.5f to FLT_EPSILON * 0.25 then you get a number that cannot be represented and it will either round to 0.5 or to 0.5 + FLT_EPSILON * 0.5
With the default rounding mode that last calculation rounds to 0.5. There are a _lot_ of floats below FLT_EPSILON.