I would like first to convert a number to binary, then invert it bitwise. Like this:
Number is 793 = 1100011001
then convert the binary value into: 0011100110
In JavaScript I can do the following:
var x = 793;
document.write(x.toString(2)); // gives 0011100110
This will give me the binary value of the number. But how do I invert the binary bitwise?
I tried the ~
operator, but not working probably. The output is: -1100011010