I seem to remember something about rounding functions and accounting.. that 
there's a rule in accounting that says if the trailing number is even you round 
down, odd you round up.. or something like that.  I know that's different than 
standard 'math' but in accounting it apparently helps deal with the fractions 
of a penny that can go missing if you always round the same direction.

Someone correct me if I'm wrong, but I suspect what you're seeing has something 
to do with that.. or could.

With that in mind, I took a look at the round function documentation at:


This note may shed some light on what you're seeing:
http://www.php.net/manual/en/function.round.php

" twain47 at gmail dot com
10-May-2005 07:25
The bankers' rounding behaviour mentioned in the notes below seems to have been 
changed to normaly rounding. 

>From the comments in http://bugs.php.net/bug.php?id=24142 it was changed in 
>4.3.0 but various bugs seem to have been introduced and it wasn't stable again 
>until 4.3.5 (http://bugs.php.net/bug.php?id=25694)
"

That may not explain it though.. "Banker's rounding" 
(http://en.wikipedia.org/wiki/Significance_arithmetic#The_round-to-even_rounding_rule)
 seems to have to do with the whole number.

I dunno..  some links to read up on though.  Good luck!

-TG

= = = Original message = = =

Hi,

I searched the archives but did not found anything.

It seem that the round function behavior has changed in php 4.4.x (I don't
have 4.4.1 handy for testing).

In 4.3.11, the output of round("23.005",2) is 23.01 which is mathematically
correct.

In 4.4.2, the output is 23 which is not correct.  The output of
round("23.0051",2) is correct though (23.01).

Is there a workaround/patch for this?

Thanks in advance

S~bas


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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

Reply via email to