note 40006 deleted from function.number-format by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 18 Feb 2004 21:58:09 +0000 |
| Subject: | note 40006 deleted from function.number-format by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65356@lists.php.net to get a copy of this message | ||
Note Submitter: jeff@skrysak.com
----
As pointed by another user, number_format *does* round
the value but only in certain cases and in certain ways.
$value = 123.76;
echo number_format($value); // prints 124
echo number_format($value, 1); // prints 123.8
echo number_format($value, 2); // prints 124.76
So what is important is the number of decimal places you specify.
If you are dealing with monetary values, such as 50 dollars and
45 cents, then make sure you specify 2 decimal places (and not 0,
1, 3, or more). That way it will show 50.45 instead of 51 or 50.450, etc...