public static BitArray of(final BigInteger value, final int length) {
		final byte[] array = Bits.newArray(length);
		final byte[] data = value.toByteArray();

		Bits.reverse(data);
		if (value.signum() < 0) {
			array[array.length - 1] = (byte)-1;
		}
		System.arraycopy(data, 0, array, 0, data.length);

		return new BitArray(array, 0, length);
	}
Creates a new bit-array from the given {@code value} and the given
{@code length}. It is guaranteed that the created bit-array will
represent the given {@link BigInteger}, as long as the {@code length}
is big enough to store the whole value. If the length is shorter than
required, the higher order bits will be truncated.

{@snippet lang="java":
final var length = 2048;
final var bint = BigInteger.probablePrime(length, new Random());
final var bits = BitArray.of(bint, length + 1);
assert bits3.toBigInteger().equals(bint);
}

@see #toBigInteger()

@param value the integer value
@param length the length of the created bit-array
@return a newly created bit-array which represent the given {@code value}
@throws NullPointerException if the given {@code value} is {@code null}
@throws NegativeArraySizeException if the {@code length} is negative
jenetics/src/main/java/io/jenetics/internal/collection/BitArray.java