Re: Round with money_format
| From: | Tedd Sperling | Date: | Sat, 17 Sep 2011 18:29:17 +0000 |
| Subject: | Re: Round with money_format | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314923@lists.php.net to get a copy of this message | ||
On Sep 17, 2011, at 10:56 AM, Bill Guion wrote:
> On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote:
>>
>> Can someone help me understand how money_format() rounds numbers ?
>>
> As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in
> graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This
> means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule.
Bill:
For many years (40+) I've claimed the same solution. I even wrote a routine to prove that
algorithm is better than the one used in round().
The only problem is that it requires millions of instances to show any significant difference. IOW,
it's simply not worth the effort.
Cheers,
tedd
_____________________
tedd@sperling.com
http://sperling.com