Reputation: 19
I'm using bit wise for one of my scripts
<?php
$num1 = 33554432;
$num2 = 975827238;
if($num2 & $num1){
echo "Yes";
}else{
echo "No";
}
?>
The problem is that it echo's Yes when it should be no, any response would be appreciated
Upvotes: 0
Views: 124
Reputation: 224858
33554432 & 975827238
is 33554432
, which is not zero, so no, it shouldn't be No.
97582723810 = 1110100010100111110001001001102 & 3355443210 = 0000100000000000000000000000002 ----------------------------------------------- 3355443210 = 0000100000000000000000000000002
Upvotes: 6