This is an issue with order of operations.
For reference, check the table of JavaScript operator precedence.
== has a precidence of 10 while & has a precidence of 9, so == gets evaluated first.
So your code is essentially evaluating:
num & (0x100 == 0x100)
Which is equivalent to:
num & true
num1 is outputted while num2 is not because:
0x200127 & true == 1 (true)
0x200124 & true == 0 (false)
Try putting your bitwise operations in parenthesis, as the grouping operator has the highest precedence of all.
if((num1 & 0x100) == 0x100){
console.log("num1: " + (num1 & 0x100 ) );
}
if((num2 & 0x100) == 0x100){
console.log("num2: " + (num2 & 0x100 ) );
}
Test it below:
var num1 = 0x200127,
num2 = 0x200124,
output = document.getElementById('output');
if ((num1 & 0x100) == 0x100) {
output.innerHTML += "<p>num1: " + (num1 & 0x100) + "</p>";
}
if ((num2 & 0x100) == 0x100) {
output.innerHTML += "<p>num2: " + (num2 & 0x100) + "</p>";
}
<div id="output"></div>