in reply to round numbers
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: round numbers
by rir (Vicar) on Oct 07, 2002 at 17:05 UTC |