note 120654 deleted from language.operators.arithmetic by salathe

From: Date: Mon, 21 Sep 2020 14:58:45 +0000
Subject: note 120654 deleted from language.operators.arithmetic by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215407@lists.php.net to get a copy of this message
Note Submitter: pr dot dot dot dot k at g dot dot dot com ---- The modulus operator is very poorly suited for such a simple operation as determining if an int is even or odd. On most common systems, modulus performs a division, which is a very slow operation. A much better way to find if a number is even or odd is to use the bitwise & operator. e.g. $is_odd = $x & 1; //using and $is_odd = $x % 2; //using modulus

« previous php.notes (#215407) next »