Disco.Services.DocumentUniqueIdentifierExtensions.BinaryNumericDecode C# (CSharp) Method

BinaryNumericDecode() public static method

public static BinaryNumericDecode ( byte Data, int Offset, int &NewOffset ) : string
Data byte
Offset int
NewOffset int
return string
        public static string BinaryNumericDecode(byte[] Data, int Offset, out int NewOffset)
        {
            int leadingZeros = (Data[Offset] & 0x30) >> 4;
            int number = ((Data[Offset] & 0x0F) << 24) |
                (Data[Offset + 1] << 16) |
                (Data[Offset + 2] << 8) |
                (Data[Offset + 3]);

            NewOffset = Offset + 4;

            if (leadingZeros == 0)
            {
                return number.ToString();
            }
            else
            {
                var builder = new StringBuilder(12); // 12 = max number length
                builder.Append('0', leadingZeros);
                builder.Append(number);
                return builder.ToString();
            }
        }