From 096b5ff5151dde2003a392d2b9632b56eb4e5f87 Mon Sep 17 00:00:00 2001 From: Andi Qu <31325319+dolphingarlic@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:00:49 -0500 Subject: [PATCH] Fix integer bounds This bug was causing our 6.2050 project to fail lmao --- src/manta/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/manta/utils.py b/src/manta/utils.py index 006b95a..67decc5 100644 --- a/src/manta/utils.py +++ b/src/manta/utils.py @@ -6,8 +6,8 @@ def pack_16bit_words(data): concatenates them together in little-endian order.""" for d in data: - if d > 0: assert d < 2**16-1, "Unsigned integer too large." - if d < 0: assert d < 2**15-1, "Signed integer too large." + if d > 0: assert d < 2**16, "Unsigned integer too large." + if d < 0: assert d < 2**15, "Signed integer too large." return int(''.join([f'{i:016b}' for i in data[::-1]]), 2) @@ -121,4 +121,4 @@ class VerilogManipulator: conn = ",\n".join(conn) conn = conn + "," if trailing_comma else conn - return conn \ No newline at end of file + return conn