note 117758 added to function.round

From: Date: Mon, 03 Aug 2015 19:30:04 +0000
Subject: note 117758 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-203254@lists.php.net to get a copy of this message
Because this function is missing round up and round down constants and the top note doesn't really show you how to round up or down to the nearest number, here is an easy way to always round up or always round down to the nearest number. int is the number you want to round n is the nearest number you want rounded to. Round up to the nearest number function round_up($int, $n) { return ceil($int / $n) * $n; } And to round down to the nearest number function round_down(int, $n) { return floor($int / $n) * $n; } ---- Server IP: 72.52.91.14 Probable Submitter: 75.141.69.219 ---- Manual Page -- http://php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/117758 Del: integrated -- https://master.php.net/note/delete/117758/integrated Del: useless -- https://master.php.net/note/delete/117758/useless Del: bad code -- https://master.php.net/note/delete/117758/bad+code Del: spam -- https://master.php.net/note/delete/117758/spam Del: non-english -- https://master.php.net/note/delete/117758/non-english Del: in docs -- https://master.php.net/note/delete/117758/in+docs Del: other reasons-- https://master.php.net/note/delete/117758 Reject -- https://master.php.net/note/reject/117758 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203254) next »