Microsoft.Automata.Chooser.GetMostSignificantBit C# (CSharp) Méthode

GetMostSignificantBit() private méthode

Calculates the value of the most significant bit in a positive integer.
private GetMostSignificantBit ( uint n ) : uint
n uint The positive integer of which the value of the most significant bit is to be /// calculated.
Résultat uint
        private uint GetMostSignificantBit(uint n)
        {
            // Do from (2^x) =1 to (2^x) =(number of bits in data type of n)/2
            n |= n >> 1;
            n |= n >> 2;
            n |= n >> 4;
            n |= n >> 8;
            n |= n >> 16;

            return n - (n >> 1);
        }