Recurity.Swf.SwfEncodedU32.SwfEncodedSizeOf C# (CSharp) Method

SwfEncodedSizeOf() public static method

Calculates the number of bytes used to encode a ulong value
public static SwfEncodedSizeOf ( ulong value ) : int
value ulong value to calculate the size of
return int
        public static int SwfEncodedSizeOf(ulong value)
        {
            int numBytes = 0;
            while (value > 0)                       // While the size of the value is greater than the
            {                                       // current number of bytes can represent
                value = value >> 7;                 // Reduce the representation of the value by 7 bit
                numBytes++;                         // that are stored is one byte
                if (value == 1)                     // If the value of the current byte is one
                    break;                          // no other byte needed
            }

            return numBytes > 0 ? numBytes : 1;     // At least one byte is used to represent a value
        }