Last active
December 17, 2015 08:39
-
-
Save chensoren/5581387 to your computer and use it in GitHub Desktop.
二进制文本转换
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//第0, 2, 5, 11位为1, 其它位为0 | |
//二进制应该为 010000100101 | |
var digitArray = ['0', '2', '5', '11']; | |
var binByte; | |
for(i=0; i<digitArray.length; i++) { | |
binByte = binByte | 1 << digitArray[i]; | |
} | |
console.log(binByte.toString(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment