note 14312 added to language.types.type-juggling.php

From: Date: Thu, 26 Jul 2001 09:10:08 +0000
Subject: note 14312 added to language.types.type-juggling.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15865@lists.php.net to get a copy of this message
It seems that sometimes, you need a little type juggling when doing bitwise operations. Here's what happened to me (this was not the exact code, but the values are the same) : $a = 7; $b = 256; Later on, I did ($a & $b) with those exact values and got a result of 7, which is mathematically wrong. To those of you who get this kind of error, it helps by converting the scalars to integer values : ((integer)$a & (integer)$b) works a lot better. Hope I saved you time Carl http://www.php.net/manual/en/language.types.type-juggling.php

« previous php.notes (#15865) next »