Thanks for posting this, I was faced with that exact same problem this week. But with the following extra constraints :<p>- Not everybody uses GCC, especially in the embedded world where CLZ is most useful<p>- It must be portable to a Cortex-M0+ that doesn&#x27;t have a CLZ instruction<p>Like me you probably end up here :<p><a href="http:&#x2F;&#x2F;embeddedgurus.com&#x2F;state-space&#x2F;2014&#x2F;09&#x2F;fast-deterministic-and-portable-counting-leading-zeros&#x2F;" rel="nofollow">http:&#x2F;&#x2F;embeddedgurus.com&#x2F;state-space&#x2F;2014&#x2F;09&#x2F;fast-determinis...</a>