We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39e1a26 commit 76bc53bCopy full SHA for 76bc53b
src/runtime/lpython/lpython.py
@@ -17,14 +17,9 @@
17
class UnsignedInteger:
18
def __init__(self, bit_width, value):
19
if isinstance(value, UnsignedInteger):
20
- if bit_width != value.bit_width:
21
- raise ValueError(f"Bit width mismatch: {bit_width} vs {value.bit_width}")
22
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.")
26
self.bit_width = bit_width
27
- self.value = value
+ self.value = value % (2**bit_width)
28
29
def __bool__(self):
30
return self.value != 0
0 commit comments