Posted by www.j2be.com on 02/10/07 23:58
> I can understand the 1 and 8 but why are 16,32,128 and 512 coming up?
> Should I go to bed and look at it in the morning when no doubt everything
> will be obvious?
Because you are using the strings and the result are related to the ascii
values.
try this
<?php
$apm = 9;
echo "APM = " . (string)$apm ."<br>";
if ($apm & 1) echo "<br>1";
if ($apm & 2) echo "<br>2";
if ($apm & 4) echo "<br>4";
if ($apm & 8) echo "<br>8";
if ($apm & 16) echo "<br>16";
if ($apm & 32) echo "<br>32";
if ($apm & 64) echo "<br>64";
if ($apm & 128) echo "<br>-128<br>";
if ($apm & 256) echo "<br>256";
if ($apm & 512) echo "<br>512";
?>
In any case use the type cast to avoid problems
expecially for this kind of (and math) operations.
Regards.
L. A. Iarrusso
Navigation:
[Reply to this message]
|