note 14945 deleted from language.types.integer by bjori

From: Date: Sat, 25 Mar 2006 21:44:13 +0000
Subject: note 14945 deleted from language.types.integer by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106610@lists.php.net to get a copy of this message
Note Submitter: carl at NOSPAM dot thep dot lu dot se ---- One note about integer division: PHP of course has the << and >> operators, so as long as you need to do integer division by a power of 2 you can just shift to the right. However, as the floating point numbers are 64-bit rather than 32-bit all possible values for a 32-bit int can be represented exactly by a float, so there is no risk of rounding errors when doing (int)(n1/n2). The overhead of converting to float and back can probably be ignored for an interpreted language like PHP, unless the engine is insanely optimized. (Testing confirms that $a/$b takes only marginally longer than $a>>$b and $a*$b for integers $a and $b.)

« previous php.notes (#106610) next »