+ * Returns the value of the BitVector as BigInteger.
+ *
+ * @throws NumberFormatException if the BitVector is not {@link #isBinary() binary}.
+ */
+ public BigInteger getUnsignedValue()
+ {
+ if (!isBinary())
+ throw new NumberFormatException(this + " is not binary");
+ byte[] bytes = new byte[(bits.length / 8) + 1];
+ for (int i = 0; i < bits.length; i++)
+ {
+ if (Bit.ONE == bits[i])
+ {
+ bytes[i / 8] |= 1 << (i % 8);
+ }
+ }
+ return new BigInteger(bytes);
+ }
+
+ /**
+ * Parses a String containing solely {@link Bit} symbols (MSB first)