Thursday, June 13, 2019

Comparing two floats/doubles in c++

I read that floats/doubles equality should be implemented using an interval (given by some epsilon):



bool aresame(double a, double b)
{
return (fabs(a-b) < EPSILON);
}


Is their any predefined value of EPSILON that I can use or do I have to define it myself, something like, 0.0000000001?

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...