Skip to content

Instantly share code, notes, and snippets.

@jacktams
Created May 2, 2016 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacktams/80dde5f2b03c9bd3f7ba805e29460068 to your computer and use it in GitHub Desktop.
Save jacktams/80dde5f2b03c9bd3f7ba805e29460068 to your computer and use it in GitHub Desktop.
function to8bitString(input){
//clamp the value to 8-bits by and with 0xFF
var clampedValue = (input&0xFF).toString(2);
//pad the string to make it easier to read.
return String("00000000" + clampedValue).slice(-8);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment