note 110346 deleted from language.operators.logical by googleguy

From: Date: Mon, 15 Oct 2012 00:17:12 +0000
Subject: note 110346 deleted from language.operators.logical by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191291@lists.php.net to get a copy of this message
Note Submitter: espertalhao04 at hotmail dot com ---- 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 ?>

« previous php.notes (#191291) next »