#32305 [Opn->Bgs]: ceil returns unexpected results

From: Date: Tue, 15 Mar 2005 05:03:19 +0000
Subject: #32305 [Opn->Bgs]: ceil returns unexpected results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75351@lists.php.net to get a copy of this message
ID: 32305 Updated by: rasmus@php.net Reported By: webmaster at ew3d dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: CentOS 4.0 PHP Version: 4.3.9 New Comment: Please read: http://php.net/manual/en/language.types.float.php You are magnifying floating point errors. No bug here. Previous Comments: ------------------------------------------------------------------------ [2005-03-15 05:16:06] webmaster at ew3d dot com Description: ------------ I'm running the current RHEL rpm php 4.3.9 i386. Reproduce code: --------------- printf(ceil(0.05*100)/100); //Returns 0.05 printf(ceil(0.06*100)/100); //Returns 0.06 printf(ceil(0.07*100)/100); //Returns 0.08 <-- Wrong printf(ceil(7)); //Returns 7 printf(ceil(0.08*100)/100); //Returns 0.08 printf(ceil(0.14*100)/100); //Returns 0.15 <-- Wrong printf(ceil(0.21*100)/100); //Returns 0.21 Expected result: ---------------- 0.05 0.06 0.07 7 0.08 0.14 0.21 Actual result: -------------- 0.05 0.06 0.08 7 0.08 0.15 0.21 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32305&edit=1

« previous php.bugs (#75351) next »