Jurassic.BigInteger.CountLeadingZeroBits C# (CSharp) Method

CountLeadingZeroBits() private static method

Returns the number of leading zero bits in the given 32-bit integer.
private static CountLeadingZeroBits ( uint value ) : int
value uint A 32-bit integer.
return int
        private static int CountLeadingZeroBits(uint value)
        {
            int k = 0;

            if ((value & 0xFFFF0000) == 0)
            {
                k = 16;
                value <<= 16;
            }
            if ((value & 0xFF000000) == 0)
            {
                k += 8;
                value <<= 8;
            }
            if ((value & 0xF0000000) == 0)
            {
                k += 4;
                value <<= 4;
            }
            if ((value & 0xC0000000) == 0)
            {
                k += 2;
                value <<= 2;
            }
            if ((value & 0x80000000) == 0)
            {
                k++;
                if ((value & 0x40000000) == 0)
                    return 32;
            }
            return k;
        }