BerLib.BerEncoding.EncodeMultiByteLong C# (CSharp) Method

EncodeMultiByteLong() public static method

public static EncodeMultiByteLong ( IBerOutput output, ulong value ) : int
output IBerOutput
value ulong
return int
        public static int EncodeMultiByteLong(IBerOutput output, ulong value)
        {
            var size = 1;

             if((value & 0x8000000000000000UL) != 0) // most significant 1 bits
             {
            output.WriteByte((byte)(0x80 | 1));
            size++;
             }

             if((value & 0xFF00000000000000UL) != 0) // most significant 8 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 56) & 0x7F)));
            size++;
             }

             if((value & 0xFFFE000000000000UL) != 0) // most significant 15 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 49) & 0x7F)));
            size++;
             }

             if((value & 0xFFFFFC0000000000UL) != 0) // most significant 22 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 42) & 0x7F)));
            size++;
             }

             if((value & 0xFFFFFFF800000000UL) != 0) // most significant 29 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 35) & 0x7F)));
            size++;
             }

             if((value & 0xFFFFFFFFF0000000UL) != 0) // most significant 36 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 28) & 0x7F)));
            size++;
             }

             if((value & 0xFFFFFFFFFFE00000UL) != 0) // most significant 43 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 21) & 0x7F)));
            size++;
             }

             if((value & 0xFFFFFFFFFFFFC000UL) != 0) // most significant 50 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 14) & 0x7F)));
            size++;
             }

             if((value & 0xFFFFFFFFFFFFFF80UL) != 0) // most significant 57 bits
             {
            output.WriteByte((byte)(0x80 | ((value >> 7) & 0x7F)));
            size++;
             }

             output.WriteByte((byte)(0x00 | ((value >> 0) & 0x7F)));

             return size;
        }