Counting the leading zeroes in a binary number with C#

added by DotNetKicks
9/20/2022 2:46:48 PM

186 Views

I recently needed an algorithm to count the number of leading zeroes in a ulong value. In this post I describe the algorithm I used and demonstrate how it works. In my work on the Datadog APM tracer, I recently needed to know the number of "leading zeroes" of a ulong value, in order to encode it efficiently.


0 comments