I have a javascript program there use bitwise OR operator to get a OR result from two numbers:
Sample code:
<!DOCTYPE html>
<html>
<body>
<p>Click the button to return the number of characters in the string "Hello World!".</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var str = "80400001";
var a = parseInt(str, 16);
var str = "12345678";
var b = parseInt(str, 16);
n = b|a;
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
But the result is always negative, that is not my expected value. Result:
-1837869447
Eventhough I try to OR a number with zero, the result is still negative...
It doesn't happen in Java, but in Javascript.
Can you tell how can I get the same result as that in Java?