cjsolomon / Mulit-Modal

SRU Multi-Modal Project
0 stars 2 forks source link

Double Comparison with equals #19

Closed ghost closed 10 years ago

ghost commented 10 years ago

The current code has precision issues. Doubles cannot be compared with equals. this test will need updated.

static public boolean inRange(double check, double min, double max)
    {
        if(check >= min && check <= max) 
        {
            return true;
        }
        else 
        {
            //Log.writeLogWarning("Invalid numerical entry given; not in range.");
            return false;
        }
    }
zgp1001 commented 10 years ago

Dan I changed the code around a bit. I'll need confirmation that the new technique is proper. I use the Double classes compare function, which returns 0 if the values are equal and test to see if it returns 0. The inequalities were changed to strict less than and greater than.

ghost commented 10 years ago

Should be fine. The test is still passing. As long as you are just using < and > there are no issues. I will go ahead and close this issue