{"issue":{"state":"open","created_at":"2011-11-23T15:19:39Z","updated_at":"2011-11-23T16:12:46Z","comments":3,"user":{"gravatar_id":"2e1599d22dce3e1661b6e63e8514b38e","id":155633,"url":"https://api.github.com/users/millermedeiros","login":"millermedeiros","avatar_url":"https://secure.gravatar.com/avatar/2e1599d22dce3e1661b6e63e8514b38e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I've seen a lot of people using `length >>> 0` on their code (including the MDN shims) but never really understood why, just want to clarify the reasoning behing it, I know what `>>>` does just don't understand why it's being used in this case..\r\n\r\nif `length` is negative it will return `Math.pow(2, 32) + length` (that's what zero-fill right shift does with negative numbers..) if length is `NaN` it will return `0` and if value is positive it will do a `Math.floor()` (because bitwise operations works with integers..)\r\n\r\nwhy not simply do `~~length`?? it will take care of `NaN` and `Math.floor()` and negative lengths will be ignored since loops won't execute..\r\n\r\n```js\r\n~~ 0.35;  // 0\r\n~~ 9.75;  // 9\r\n~~ -9.75; // -9\r\n~~ '';    // 0\r\n~~ 'foo'; // 0\r\n~~ NaN;   // 0\r\n```\r\n\r\nin the current setup if `self.length` is negative (probably won't happen :P) it will cause an \"infinite\" loop.","assignee":null,"id":2330647,"number":78,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"title":"question: why `self.length >>> 0`?","closed_at":null,"html_url":"https://github.com/kriskowal/es5-shim/issues/78","milestone":null,"url":"https://api.github.com/repos/kriskowal/es5-shim/issues/78"},"action":"created","comment":{"created_at":"2011-11-23T16:12:46Z","updated_at":"2011-11-23T16:12:46Z","user":{"gravatar_id":"24fb0088507077f7852adaec4f6b679f","id":218840,"url":"https://api.github.com/users/michaelficarra","login":"michaelficarra","avatar_url":"https://secure.gravatar.com/avatar/24fb0088507077f7852adaec4f6b679f?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I don't know what you mean by \"the `ToUInt32 spec is *wrong*\". What could be wrong about it? It's whatever they define it to be. If you mean es5.github.com differs from the offical ecma-262 pdf in section 9.6, that's incorrect. I just verified that they're the same.","id":2850657,"url":"https://api.github.com/repos/kriskowal/es5-shim/issues/comments/2850657"}}