5-4. Counting Trailing 0’s

If the number of leading zeros instruction is available, then the best way to count trailing 0’s is, most likely, to convert it to a count leading 0’s problem:

If population count is available, a slightly better method is to form a mask that identifies the trailing 0’s, and count the 1-bits in it [Hay2], such as

Variations exist using other expressions for forming a mask that identifies the trailing zeros of x, such as those given in Section 2-1,“Manipulating Rightmost Bits” on page 11. These methods are also reasonable ...

Get Hacker's Delight now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.