From df83f4650c28208e1cafff0742189fda97410a5a Mon Sep 17 00:00:00 2001 From: Fabian Stemmler Date: Wed, 28 Aug 2019 21:34:40 +0200 Subject: [PATCH] Fixed getUnsignedValue() in BitVector Fixed getUnsignedValue() for good this time; Bit order MSB to LSB is now correctly incorporated. --- .../net/mograsim/logic/core/types/BitVector.java | 14 +++++++++++--- .../mograsim/logic/core/types/BitVectorTest.java | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java index c223e819..8f53a36b 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java @@ -420,13 +420,13 @@ public final class BitVector implements StrictLogicType, Iterable= 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) { @@ -477,4 +477,12 @@ public final class BitVector implements StrictLogicType, Iterable BitVector.parse("00X1").getUnsignedValue()); - } @Test -- 2.17.1