Created
December 1, 2016 10:15
-
-
Save anonymous/45b00bb7b810a153af6d58d8f7c77f5d to your computer and use it in GitHub Desktop.
This file contains 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
function h2b(hexin){ | |
return parseInt(hexin, 10).toString(2); | |
} | |
//from http://stackoverflow.com/a/12987042 | |
function d2h(n){return n.toString(16).toUpperCase()} | |
function conv(hexin){ | |
console.log('0x'+d2h(hexin)+':'+h2b(hexin)); | |
} | |
/* | |
#Example usage | |
conv(0x1F); | |
#Example output | |
0x1F:11111 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment