System.Numerics.Tests.cast_fromTest.ByteArrayMakeMinSize C# (CSharp) Method

ByteArrayMakeMinSize() public static method

public static ByteArrayMakeMinSize ( Byte input, int minSize ) : byte[]
input Byte
minSize int
return byte[]
        public static byte[] ByteArrayMakeMinSize(Byte[] input, int minSize)
        {
            if (input.Length >= minSize)
            {
                return input;
            }

            Byte[] output = new byte[minSize];
            Byte filler = 0;

            if ((input[input.Length - 1] & 0x80) != 0)
            {
                filler = 0xff;
            }

            for (int i = 0; i < output.Length; i++)
            {
                output[i] = (i < input.Length) ? input[i] : filler;
            }

            return output;
        }
    }