note 95674 deleted from function.round by thiago
| From: | thiago@php.net | Date: | Fri, 15 Jan 2010 12:10:30 +0000 |
| Subject: | note 95674 deleted from function.round by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164994@lists.php.net to get a copy of this message | ||
Note Submitter: cpopa at nu-dawn dot ca
----
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).
?>