Skip to content

Misleading documentation for int.operator>> #11316

@RevolNoom

Description

@RevolNoom

Issue description:
-1/2 does not equal to -1 >> 1

Documentation for operator>> says: "Effectively the same as dividing by a power of 2".
This is only true when the integer is non-negative.
When shifted right, the new bits will have the value of the (previously) most significant bit.
Example:
0xF000_0000_0000_0000 >> 12 is 0xFFFF_0000_0000_0000
0x0F00_0000_0000_0000 >> 12 is 0x0000_F000_0000_0000
Negative numbers will converge to -1, and other numbers will converge to 0.

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/classes/class_int.html#class-int-operator-bwsr-int

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:class referenceIssues and PRs about the class reference, which should be addressed on the Godot engine repositorydiscussionenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions