Bug #2835 Updated: floor (8.28 * 100) = 8.27

From: Date: Fri, 26 Nov 1999 15:59:59 +0000
Subject: Bug #2835 Updated: floor (8.28 * 100) = 8.27
Groups: php.dev 
Request: Send a blank email to php-dev+get-13143@lists.php.net to get a copy of this message
ID: 2835 Updated by: rasmus Reported By: aulbach@unter.franken.de Status: Closed Bug Type: Misbehaving function Assigned To: Comments: Your mistake is that you think that floating point values are absolute. They are not. 8.28 is not 8.28 but actually 8.27999999999999999999999999999 or 8.280000000000000000001 If you want to force a certain behaviour when rounding floating point numbers you will need to add a fuzz factor to compensate for the computer's inability to store absolute floating point numbers. eg. $fuzz = 0.000000001; echo round(3/2 + $fuzz); This would make sure that a x.5 value would always be rounded up, for example. Full Bug description available at: http://bugs.php.net/?id=2835

« previous php.dev (#13143) next »