Skip to content

Commit 76bc53b

Browse files
committed
lpython.py: Fix unsigned cast for CPython
1 parent 39e1a26 commit 76bc53b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/runtime/lpython/lpython.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717
class UnsignedInteger:
1818
def __init__(self, bit_width, value):
1919
if isinstance(value, UnsignedInteger):
20-
if bit_width != value.bit_width:
21-
raise ValueError(f"Bit width mismatch: {bit_width} vs {value.bit_width}")
2220
value = value.value
23-
24-
if not (0 <= value < 2**bit_width):
25-
raise ValueError(f"Value should be in range 0 to {2**bit_width-1} for a {bit_width}-bit unsigned integer.")
2621
self.bit_width = bit_width
27-
self.value = value
22+
self.value = value % (2**bit_width)
2823

2924
def __bool__(self):
3025
return self.value != 0

0 commit comments

Comments
 (0)