RE: [PHP] rounding up

2001-04-27 Thread Joseph Bannon

What is the best seamless way to upgrade/update PHP?

Joseph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] rounding up

2001-04-25 Thread Matt Williams

Hi

 
 Is there a PHP command to round up to the nearest integer?

www.php.net/ceil
www.php.net/round

HTH

M@

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] rounding up

2001-04-25 Thread John Huggins


  Is there a PHP command to round up to the nearest integer?

 www.php.net/ceil
 www.php.net/round


These are the correct functions, but take great care in reading the user
contributed notes in the round function concerning x.5 rounding randomness.
Sometimes this can get you.

If you want to be sure 4.5 always rounds to 5, add a fudge factor smaller
than your precision, but larger than the precision of the computer.

$value = 4.5;
$fudge = 0.001;

round($value) sometimes returns 5
round($value) sometimes returns 4

$fudgedvalue = $value + $fudge;

round($fudgedvalue) = 5

This comes into play often when you do things like split a long list of
items into two columns on your web page and you use PHP (or any language) to
figure out where to end the first column and start the second.

It should be noted that this is not a PHP issue.  It affects any language
which relies on the hardware to compute.

Fun stuff eh?

John


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]