core icon indicating copy to clipboard operation
core copied to clipboard

Bitwise shifts should mention that only 5 lowest bits of shift value are used

Open malaire opened this issue 6 years ago • 1 comments

The functions Bitwise.shiftLeftBy, Bitwise.shiftRightBy and Bitwise.shiftRightZfBy only use lowest 5 bits of the shift value.

For example following two commands are equal:

Bitwise.shiftLeftBy  1 10
Bitwise.shiftLeftBy 33 10

This should be mentioned in documentation of these functions.

malaire avatar Nov 16 '19 01:11 malaire

Seems like the examples are consistent with the underlying behavior of << in JavaScript and in C.

C at least gives a warning when it sees a integer literal over the sensible limit. Not sure the best course of action on this, but could be a breaking change if the "sensible" option is to check for shifts that would zero everything out and do that.

evancz avatar Feb 09 '21 18:02 evancz