user1642026
user1642026

Reputation: 19

Bitwise not working

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

Answers (1)

Ry-
Ry-

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

Related Questions