diff --git a/src/runtime/lpython/lpython.py b/src/runtime/lpython/lpython.py index cf5c7d4de9..b511b5cfac 100644 --- a/src/runtime/lpython/lpython.py +++ b/src/runtime/lpython/lpython.py @@ -708,5 +708,10 @@ def __call__(self, *args, **kwargs): self.fn_name) return function(*args, **kwargs) -def bitnot(x): - return ~x +def bitnot(x, bitsize): + return (~x) % (2 ** bitsize) + +bitnot_u8 = lambda x: bitnot(x, 8) +bitnot_u16 = lambda x: bitnot(x, 16) +bitnot_u32 = lambda x: bitnot(x, 32) +bitnot_u64 = lambda x: bitnot(x, 64)