note 41794 added to function.ceil

From: Date: Thu, 22 Apr 2004 09:51:20 +0000
Subject: note 41794 added to function.ceil
Groups: php.notes 
Request: Send a blank email to php-notes+get-68519@lists.php.net to get a copy of this message
IceKarma said: "If you want, say, 2.6 to round to 3, and -2.6 to round to -3, you want round(), which rounds away from zero." That's not always true. round() doesn't work that way, like zomis2k said it just rounds up _or_ down to the nearest non-decimal number. However this should work. <?php function roundaway($num) { if ($num > 0) return ceil($num); elseif ($num < 0) return floor($num); elseif ($num == 0) return 0; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.ceil.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41794 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41794&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41794&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68519) next »