Simple, really. Is 0xf12345678>>>4 always supposed to produce 0x1234567 as a result in JavaScript? Can I assume this would work in all browsers?
Simple, really. Is 0xf12345678>>>4 always supposed to produce 0x1234567 as a result in JavaScript?
Share
Yes, according to the ECMAScript 5 specification, the
>>>operator performs the internalToUInt32algorithm.See Section 11.7.3 of the spec:
It is spelled out very clearly that the result is a 32-bit integer, always.
The
>>>operator is used commonly to convert to a 32-bit unsigned integer. For instance, MDN uses it in their shims. Example: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach#Compatibility