Why, after 11100, pops up 420, not 00100, but the final value (11000) still matches the original one?
var sir = 11000; alert(sir); var meg = 11100; alert(meg); var tun = sir ^ meg; alert(tun); alert(tun ^ meg); Why, after 11100, pops up 420, not 00100, but the final value (11000) still matches the original one?
var sir = 11000; alert(sir); var meg = 11100; alert(meg); var tun = sir ^ meg; alert(tun); alert(tun ^ meg); You write 2 numbers in decimal notation. The ^ (XOR) operation is performed on the bits (!) That represent these 2 numbers.
Those.
11000 10 = 10101011111000 2
11100 10 = 10101101011100 2
Applying to them the operation ^ we get the following:
00000110100100 2 = 420 10
(a XOR b) XOR b = atoString() method is what you need. Number(sir.toString(2)); - will give a binary representation of the number in the sir variable. But the XOR over this representation will not work anyway :) The line above will give a decimal number and the XOR will work with the bits of this decimal number. As a result, there will be a game - Dmitry(parseInt(sir, 2) ^ parseInt(meg, 2)).toString(2) - DmitrySource: https://ru.stackoverflow.com/questions/937183/
All Articles
0b- ArchDemon