note 80757 deleted from function.round by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:16:02 +0000 |
| Subject: | note 80757 deleted from function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154780@lists.php.net to get a copy of this message | ||
Note Submitter: denis at softmaster dot com dot ua
----
There is a bug like round up (100*1.1);
In PHP round_up(100*1.1) you got 110.01;
A true value is 100*1.1 = 110;
A elegant decision of this problem (money round up) is:
<?
// Money round up
function mround($value) {
return ceil((string)($value*100))/100;
}
?>
(string)($value*100) - this is decision! =)