floating-point

Finding the maximum of a floating point counter

+1
+1
-1

My apologies if this has been asked before, but I cannot find it.

I was wondering if there is a way to calculate the point at which a single precision floating point number that is used as a counter will reach a 'maximum' (the point at which it is no longer able to add another value due to loss of precision).

For example, if I continuously add 0.1f to a float I will eventually reach a point where the value does not change

Answer 7

+1
+1
-1

Yes it is possible. there is std::numeric_limits::epsilon() which defines smallest value which can increase value 1.0.

Using this you can calculate this limit for any number.

In C there is DBL_EPSILON

So in your case this goes like this: