From: thepurpleblob Date: Thu, 13 Apr 2006 10:29:20 +0000 (+0000) Subject: Don't compare floats for equality! Bug #5176 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2784b982782a732ad258bb53572852c058d6d91e;p=moodle.git Don't compare floats for equality! Bug #5176 --- diff --git a/lib/questionlib.php b/lib/questionlib.php index 90f6b22863..75a044a454 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -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; } }