I have the following string in JavaScript:
"1011100111100110101110110"
.
I want to perform an operation on it, that will return its complement (aka, all the ones replaced by zeros and all the zeroes replaced by ones).
The javascript documentation says the NOT operator will do exactly that, but in my tests, it does not give me what I expect.
I guess my types are wrong to start off with.
This is my test code:
var nMyNumber = "1011100111100110101110110";
var sBinString = nMyNumber.toString(2);
console.log("Number: " + sBinString);
var reverse = ~sBinString;
console.log("Complement: " + reverse);