Last active
April 20, 2022 08:19
-
-
Save lancejpollard/86359ed3f2b832044c265f2e4f633bad to your computer and use it in GitHub Desktop.
Generate count leading zeroes table
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 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