4 ms·
Pretty neat. You can see this exact approach in the Go standard library: https://golang.org/src/math/bits/bits.go#L35 https://golang.org/src/math/bits/bits.go#L
by nemo1618 8y ago
Pretty neat. You can see this exact approach in the Go standard library: https://golang.org/src/math/bits/bits.go#L35 https://golang.org/src/math/bits/bits.go#L35
Nowadays, of course, ctz gets compiled down to a single instruction (e.g. bsf on x86) :)