Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d24f993

Browse files
committedJul 18, 2023
lpython.py: Support bitnot()
1 parent 0526397 commit d24f993

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎src/runtime/lpython/lpython.py

+8
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)