I have some code that I will simplify to this:
double x;
double y;
double z;
.
.
while (x + y != z)
do stuff;
The problem is that x + y is very close to z but somewhere in my code it looses precision and so is x + y is a bit off. I have tried things like:
while (x + y + 0.0001 > z && x + y - 0.0001 < z) but I wanna do something more general. Is there some notation / function like this:
while (x + y != nextdouble(z) && x + y != prevdouble(z) && x + y != z)
where nextdouble() would give the smallest possible double greater than the parameter.