floating-point

×

Error message

  • Notice: Undefined index: value in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type bool in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type null in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type bool in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type null in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).

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: