]> git.mjollnir.org Git - moodle.git/commitdiff
Don't compare floats for equality! Bug #5176
authorthepurpleblob <thepurpleblob>
Thu, 13 Apr 2006 10:29:20 +0000 (10:29 +0000)
committerthepurpleblob <thepurpleblob>
Thu, 13 Apr 2006 10:29:20 +0000 (10:29 +0000)
lib/questionlib.php

index 90f6b22863be471cff81450345f579fad226c363..75a044a45456896e9bad4d0bd5f76f29fe47bb11 100644 (file)
@@ -260,7 +260,8 @@ function match_grade_options($gradeoptionsfull, $grade, $matchgrades='error') {
     // if we just need an error...
     if ($matchgrades=='error') {
         foreach($gradeoptionsfull as $value => $option) {
-            if ($grade==$value) {
+            // slightly fuzzy test, never check floats for equality :-)
+            if (abs($grade-$value)<0.00001) {
                 return $grade;
             }
         }