Hi! In the question SEAVOTE of current Long Challenge, I have made an algorithm that needs comparison among doubles. But, only 4/5 test cases pass and that too of Set 1. I searched out things and found that there’s something up with the doubles while performing the comparison. My algorithm is correct, I reckon. How do I deal with this double trouble?
You can use this for your purpose:
bool AreSame(double a, double b)
{
return fabs(a - b) < EPSILON;
}
Or, if you want more detail then go through this link: Comparing floating point numbers
Hi! I need to do something like:
double b=something
if(b<=10) //do this
What is A or Ai??