Skip to content

Commit

Permalink
lpython.py: Support bitnot()
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Jul 18, 2023
1 parent b6b09ec commit f920fa6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/runtime/lpython/lpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f920fa6

Please sign in to comment.