diff options
Diffstat (limited to 'src/math/bits/make_tables.go')
| -rw-r--r-- | src/math/bits/make_tables.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/math/bits/make_tables.go b/src/math/bits/make_tables.go index 7127bdf413..c66afb5a96 100644 --- a/src/math/bits/make_tables.go +++ b/src/math/bits/make_tables.go @@ -30,6 +30,7 @@ package bits func main() { buf := bytes.NewBuffer(header) + gen(buf, "ntz8tab", ntz8) gen(buf, "pop8tab", pop8) gen(buf, "rev8tab", rev8) // add more tables as needed @@ -58,6 +59,14 @@ func gen(w io.Writer, name string, f func(uint8) uint8) { fmt.Fprint(w, "\n}\n\n") } +func ntz8(x uint8) (n uint8) { + for x&1 == 0 && n < 8 { + x >>= 1 + n++ + } + return +} + func pop8(x uint8) (n uint8) { for x != 0 { x &= x - 1 |
