Re: round()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:22 AM -0400 10/11/07, Nathan Nobbe wrote:
On 10/11/07, tedd <<mailto:tedd@xxxxxxxxxxxx>tedd@xxxxxxxxxxxx> wrote:

At 4:18 PM -0600 10/10/07, <<mailto:admin@xxxxxxxxxxxxxxxxxxx>admin@xxxxxxxxxxxxxxxxxxx> wrote:
I disagree. I will need to see an example where the round() is inaccurate.


You may disagree if you wish, but the php function round() is
inaccurate by definition -- all *rounding* algorithms are inaccurate.


thats why i suggested the bcmath based algorithm, as bcmath supports arbitrary
precision. i built a quick test script using the method from the top comment of the bcmath page, and round(). it allows for quick comparisons of the 2 algorithms and tells you if the results are the same. i messed around w/ it a little bit and the results
were the same every time.

Well, if the results were the same, then both exhibit the same accuracy bias in rounding.

However, precision is not the issue. There's a difference between precision and accuracy and I am addressing accuracy.

For example, if the answer is 4.5, then 4.4 is more accurate than 4.39999999999, but the later is more precise.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux