Skip to content

shr naming consistency resolution #25059

@capocasa

Description

@capocasa

shr performs an arithmetic right shift on signed integers, and a logical right shift on unsigned integers.

(1) While the documentation is clear for signed integers, the behavior for unsigned integers isn't specified. This would be easy enough to fix in documentation.

(2) ashr makes sense in this context, as it is an explicit arithmetic right shift, supported only on signed integers. It's weird that it can't be called as an operator.

(3) It would be really cheap to add an lshr operator that only applies to unsigned integers for consistency.

(4) Of course it would be nice for ashr to also support signed integers, and the proposed lshr to also support signed integers

Not saying anything yet about who would shoulder the implementation burden, I just wanted to check if there is agreement on the status and what would be desirable and/ or easy.

Note: previous version removed, as it was based on incorrect understanding.

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