godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Misleading documentation for int.operator>>

Open RevolNoom opened this issue 2 months ago • 1 comments

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

RevolNoom avatar Sep 22 '25 12:09 RevolNoom