For downward rounding, you'd always want to use floor() and use ceil() for 
rounding up.  round() rounds up on a 5, down on a 4 and below.

Example:
echo round(141.074, 2);  // 141.07
echo round(141.065, 2);  // 141.07


I thought round() (or maybe it was a rounding function in another language or 
something like Excel) did the supposed accounting trick of rounding up and down 
depending on the next "significant digit" or whatever you'd call it.

For example, 141.075 might round to 141.08 (because 7 is odd) and 141.065 might 
round to 141.06 (because 6 is even).  Or vice versa.  Supposedly this is an 
accounting trick that ultimatley works out in the end for proper rounding of 
money values.  Guess our PHP 4.3.4 here doesn't do that though.

-TG




= = = Original message = = =

At 7:57 PM +0100 2/12/07, Marc Weber wrote:
>On Mon, 12 Feb 2007 18:02:41 +0100, <[EMAIL PROTECTED]> wrote:
>
>>Is there an easy way in php to round to the nearest 500?
>Yeah
>$rouned = round($val/500) * 500;

I've always questioned the round() function.

I believe it has a downward bias, am I wrong?

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


___________________________________________________________
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