Tag: tostring

JavaScript按位屏蔽

这个问题与其他问题类似, 不过,我想了解为什么这样工作。 以下代码: console.log((parseInt('0xdeadbeef', 16) & parseInt('0x000000ff', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0x0000ff00', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0x00ff0000', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0xff000000', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0x000000ff', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0x0000ffff', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0x00ffffff', 16)).toString(16)); console.log((parseInt('0xdeadbeef', 16) & parseInt('0xffffffff', 16)).toString(16)); 返回: ef be00 ad0000 -22000000 ef beef adbeef -21524111 当我期望从.string(16)将是: ef be00 […]