The whole ONES... HASZERO shenanigans is somewhat explained here: <a href="https:&#x2F;&#x2F;graphics.stanford.edu&#x2F;~seander&#x2F;bithacks.html#ZeroInWord" rel="nofollow">https:&#x2F;&#x2F;graphics.stanford.edu&#x2F;~seander&#x2F;bithacks.html#ZeroInW...</a> as well as the entry after it.<p>Edit: And most likely in the excellent book &quot;Hacker&#x27;s Delight&quot; as well.