A bit manipulation readability enhancement library.
Computes the number of sequentially zeroed bits occupying the most significant bit positions.
public static int CountLeadingZeros(this ulong number);
number
System.UInt64
The number to evaluate.
System.Int32 The count of sequentially zeroed bits occupying the most significant bit positions.
ulong v = 0x7FFFFFFF_FFFFFFFF;
Console.WriteLine($"{v.CountLeadingZeros()}"); // outputs: 1
v = 0x3FFFFFFF_FFFFFFFF;
Console.WriteLine($"{v.CountLeadingZeros()}"); // outputs: 2
v = 1;
Console.WriteLine($"{v.CountLeadingZeros()}"); // outputs: 63