Am Mon, Nov 22, 2021 at 04:10:15PM +0100 schrieb Giulio Paci:
> The failing test case relies on the assumptions that, when a and b have the
> same double value:
> 2) "a - b" is 0.0.

(comment only based on this mail, did not check the code)

usually (C,C++) you cannot reliably say "if ( (a - b) == 0 )" or "if (a == b)"
as floating point cannot always represent the numbers exactly enough.

Usually comparing floats for almost-equality is done, something like

if (fabs(a - b) <= FLT_EPSILON)

(but FLT_EPSILION (or DBL_EPSILON) might not always be suitable, for example it
depends how much rounding you might have picked up on the way

--
tobi

Reply via email to