Skip to content

Instantly share code, notes, and snippets.

Created December 1, 2016 10:15
Show Gist options
  • Save anonymous/45b00bb7b810a153af6d58d8f7c77f5d to your computer and use it in GitHub Desktop.
Save anonymous/45b00bb7b810a153af6d58d8f7c77f5d to your computer and use it in GitHub Desktop.
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