Skip to content

Instantly share code, notes, and snippets.

@lancejpollard
Last active April 20, 2022 08:19
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 lancejpollard/86359ed3f2b832044c265f2e4f633bad to your computer and use it in GitHub Desktop.
Save lancejpollard/86359ed3f2b832044c265f2e4f633bad to your computer and use it in GitHub Desktop.
Generate count leading zeroes table
function makeLeadingZeroTable() {
let i = 0
const table = new Uint8Array(256)
while (i < 256) {
let count = 8
let index = i
while (index > 0) {
index = (index / 2) | 0
count--
}
table[i] = count
i++
}
return table
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment