Removed superfluous main method in BitVector
[Mograsim.git] / net.mograsim.logic.core / src / net / mograsim / logic / core / types / BitVector.java
index c223e81..4e0fe0b 100644 (file)
@@ -420,13 +420,13 @@ public final class BitVector implements StrictLogicType<BitVector>, Iterable<Bit
                if (!isBinary())
                        throw new NumberFormatException(this + " is not binary");
                byte[] bytes = new byte[(bits.length / 8 + (bits.length % 8 == 0 ? 0 : 1)) + 1];
-               for (int i = 0; i < bits.length; i++)
+               for (int i = bits.length - 1; i >= 0; i--)
                {
-                       if (Bit.ONE == bits[i])
+                       if (Bit.ONE == bits[bits.length - i - 1])
                        {
                                try
                                {
-                                       bytes[(i / 8) + 1] |= 1 << (i % 8);
+                                       bytes[bytes.length - (i / 8) - 1] |= 1 << (i % 8);
                                }
                                catch (IndexOutOfBoundsException e)
                                {