note 95674 added to function.round

From: Date: Fri, 15 Jan 2010 08:41:12 +0000
Subject: note 95674 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-164989@lists.php.net to get a copy of this message
I've posted some days ago a misbehavior of round function... I guess somebody didn't like it, cause i can't see it anymore... I'll try one more time: <?php $a=1527.045; round($a,2)=1527.05 //correct // but if we try doing this: $b=20.5; $c=74.49; $e=$b*$c; // that would be 1527.045 //and now apply round: round($e,2)=1527.04; //Wrong!! // the only way to be sure you get all the time right answer is to make $e a string before rounding: settype($e,"string"); round($e,2)=1527.05 // correct // funtion round() misbehaves in PHP Version 4.3.10,PHP Version 5.1.6 (i've tested on both this versions). ?> ---- Server IP: 216.235.13.26 Probable Submitter: 174.3.81.225 ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/95674 Del: integrated -- https://master.php.net/note/delete/95674/integrated Del: useless -- https://master.php.net/note/delete/95674/useless Del: bad code -- https://master.php.net/note/delete/95674/bad+code Del: spam -- https://master.php.net/note/delete/95674/spam Del: non-english -- https://master.php.net/note/delete/95674/non-english Del: in docs -- https://master.php.net/note/delete/95674/in+docs Del: other reasons-- https://master.php.net/note/delete/95674 Reject -- https://master.php.net/note/reject/95674 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164989) next »