You could use POSIX, like husoft suggested, or use int:
$num = 5.2; if ($num > 0) { $floor = int($num); $ceil = int($num) == $num ? $num : int($num)+1; } else { $floor = int($num) == $num ? $num : int($num)-1; $ceil = int($num); }
Updated: updated to deal with negative numbers correctly, as rir pointed out.
-- Dan
In reply to Re: round numbers
by zigdon
in thread round numbers
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |