PHP 4.0 Bug #6220 Updated: floor((0.7+0.1)*10) wrong

From: Date: Thu, 17 Aug 2000 16:42:34 +0000
Subject: PHP 4.0 Bug #6220 Updated: floor((0.7+0.1)*10) wrong
Groups: php.dev 
Request: Send a blank email to php-dev+get-29310@lists.php.net to get a copy of this message
ID: 6220 Updated by: hholzgra Reported By: rockojfonzo@gmx.net Status: Closed Bug Type: Misbehaving function Assigned To: Comments: (and it's the same in C) this is related to binary float representation in microprocessors .7 and .1 are periodic fractions in binary system so you get minimal rounding errors so (0.7+0.1)*10) will result in something almost 8.0 but with a minimal positive or negative offset this usualy dosn't matter as rounding will be applied but it does matter for floor() as in this case the result is a very little less than 8 conclusion: if you need the precisision than use bc Full Bug description available at: http://bugs.php.net/?id=6220

« previous php.dev (#29310) next »