Skip to content

Instantly share code, notes, and snippets.

@nuysoft
Created January 15, 2015 16:49
Show Gist options
  • Save nuysoft/16c4d3f36a38e98b6e4e to your computer and use it in GitHub Desktop.
Save nuysoft/16c4d3f36a38e98b6e4e to your computer and use it in GitHub Desktop.
解析倍增数
function parse(result) {
var cursor = 1,
arr = []
while (cursor <= result) {
if (result & cursor) arr.push(cursor)
cursor *= 2
}
console.log(arr)
}
for (var i = 0; i < 100; i++) {
parse(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment