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 0526397 commit d24f993
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/runtime/lpython/lpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,11 @@ def __call__(self, *args, **kwargs):
function = getattr(__import__("lpython_module_" + self.fn_name),
self.fn_name)
return function(*args, **kwargs)

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 d24f993

Please sign in to comment.