Skip to content

Instantly share code, notes, and snippets.

@LottieVixen
Forked from anonymous/conv.js
Created January 4, 2021 13:59
Show Gist options
  • Save LottieVixen/ae19a4d4b80e2ba66552b73d75638576 to your computer and use it in GitHub Desktop.
Save LottieVixen/ae19a4d4b80e2ba66552b73d75638576 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