note 110346 added to language.operators.logical

From: Date: Sun, 14 Oct 2012 11:04:17 +0000
Subject: note 110346 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-191283@lists.php.net to get a copy of this message
if you want to round values down with EXTREME performance, use (number)>>1. example: <?php echo (57>>1);//28 echo round(57/2,0,PHP_ROUND_HALF_DOWN);//28 ?> if you want to round UP, add 1: <? echo (58>>1);//29 echo round(57/2,0,PHP_ROUND_HALF_UP);//29 ?> all in a function: <?php function bit_round($n,$u=false) { return ($n+(bool)$u)>>1; } echo bit_round(57);//return 28 echo bit_round(57,true);//return 29 ?> ---- Server IP: 69.147.83.199 Probable Submitter: 95.136.43.99 ---- Manual Page -- http://www.php.net/manual/en/language.operators.logical.php Edit -- https://master.php.net/note/edit/110346 Del: integrated -- https://master.php.net/note/delete/110346/integrated Del: useless -- https://master.php.net/note/delete/110346/useless Del: bad code -- https://master.php.net/note/delete/110346/bad+code Del: spam -- https://master.php.net/note/delete/110346/spam Del: non-english -- https://master.php.net/note/delete/110346/non-english Del: in docs -- https://master.php.net/note/delete/110346/in+docs Del: other reasons-- https://master.php.net/note/delete/110346 Reject -- https://master.php.net/note/reject/110346 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191283) next »