note 37383 deleted from function.round by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:24:41 +0000 |
| Subject: | note 37383 deleted from function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154821@lists.php.net to get a copy of this message | ||
Note Submitter: PiotrL
----
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