Forum Moderators: coopster
ceiling. goes up. ceil($x)
floor. goes down. floor($x)
round. goes to the nearest integer. round($x)
Did you know:
In my version of PHP,
round(0.5)=1
round(1.5)=2
round(2.5)=3
round(3.5)=4
round(4.5)=5
(a quick test confirms this)
But in an ideal mathematical world,
round(0.5)=0,
round(1.5)=2,
round(2.5)=2,
round(3.5)=4,
round(4.5)=4.
A good rounding of a half should go to the nearest even number. That way, on average half of the "halves" go up, and half go down. That way statistical averages aren't badly skewed by rounding. PHP 4.3.6 doesn't do that, even though the online PHP manual shows a user comment contradicting this.