c++ - Detect zero after std::remainder() call on doubles -
i have code:
double = remainder(92.66, 0.01); double b = remainder(92.87, 0.01);
and turns out a = -5.33948e-15
and b = -2.61423e-15
the reply here zero, , if multiplied both numbers 100 , did integer modulus be. i'd able using doubles. problem remainder returning number bigger dbl_epsilon - correct(best approximation) way determine whether a
or b
~zero?
dbl_epsilon
smallest quantity can added 1.0. if number larger 1.0, epsilon number proportionately larger well. multiply dbl_epsilon
number threshold.
double = remainder(92.66, 0.01); if (a <= dbl_epsilon * 92.66) = 0.0;
c++ modulus
No comments:
Post a Comment