Bug #16544: Floating point calculation bug or float() function bug

From: Date: Thu, 11 Apr 2002 08:55:50 +0000
Subject: Bug #16544: Floating point calculation bug or float() function bug
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-4633@lists.php.net to get a copy of this message
From: chris@owta.net Operating system: Windows PHP version: 4.1.2 PHP Bug Type: Math related Bug description: Floating point calculation bug or float() function bug Here's the code <? $quantities = array(5000.00, 1000.00, 200.00); $amount = 6200; debug($quantities); foreach ($quantities as $quantity) { $divVal = ($amount/$quantity); echo ++$i.". Quantity:\n".$quantity."<BR>"; echo "divVal: ".$divVal." - ".var_dump($divVal)."<BR>\n"; echo "Amount: ".$amount."\n"; if (floor($divVal) > 0) { echo "&nbsp;[floored divVal is greater than zero]\n"; $amount = ($divVal - floor($divVal)) * $quantity; } echo "<BR><BR>"; } ?> You'll see the floor function is operating incorrectly? -- Edit bug report at http://bugs.php.net/?id=16544&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=16544&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=16544&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=16544&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=16544&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=16544&r=support Expected behavior: http://bugs.php.net/fix.php?id=16544&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=16544&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=16544&r=submittedtwice

« previous php.bugs (#4633) next »