Skip to content

Commit 9701c9e

Browse files
committed
lpython.py: Support bitnot()
1 parent 66e5d15 commit 9701c9e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/runtime/lpython/lpython.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,3 +707,11 @@ def __call__(self, *args, **kwargs):
707707
function = getattr(__import__("lpython_module_" + self.fn_name),
708708
self.fn_name)
709709
return function(*args, **kwargs)
710+
711+
def bitnot(x, bitsize):
712+
return (~x) % (2 ** bitsize)
713+
714+
bitnot_u8 = lambda x: bitnot(x, 8)
715+
bitnot_u16 = lambda x: bitnot(x, 16)
716+
bitnot_u32 = lambda x: bitnot(x, 32)
717+
bitnot_u64 = lambda x: bitnot(x, 64)

0 commit comments

Comments
 (0)