note 37383 added to function.round
| From: | PiotrL at rn2 dot php dot net | Date: | Wed, 12 Nov 2003 22:44:03 +0000 |
| Subject: | note 37383 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60323@lists.php.net to get a copy of this message | ||
There are many ways to round floating-point numbers.
And many valid (!) algorithms. This is because the algorithm depends on the domain of value and
sometimes on... country.
For example as far as I know in my country money is rounded in the same way as in math calculations:
1.4 => 1
1.5 => 2
1.6 => 2
and
2.5 => 3
A lot of rounding algorithms (and very easy to implement in every language) can be found here:
http://www.merlyn.demon.co.uk/pas-chop.htm
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37383
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37383&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37383&report=yes
Search -- http://master.php.net/manage/user-notes.php