Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for bitwise left and right shift operators in UnsignedInteger class #2150

Closed
@emoise-gsi

Description

@emoise-gsi

In lpython v18.1, the class UnsignedInteger, defined in lpython.py doesn't support bitwise shift operators. Please add something like:

    def __lshift__(self, other):
        if isinstance(other, self.__class__):
            return UnsignedInteger(self.bit_width, self.value << other.value)
        else:
            raise TypeError("Unsupported operand type")

    def __rshift__(self, other):
        if isinstance(other, self.__class__):
            return UnsignedInteger(self.bit_width, self.value >> other.value)
        else:
            raise TypeError("Unsupported operand type")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions