Re: [whatwg/encoding] "For logical right shifts operands must have at ..." (#250)

I actually misread that sentence as talking about the result of right shifts, rather than to the operands, which is why I thought it must be referring to left shifts. But although that message is indeed right in that bit shifts do depend on the size of the input, that only makes a difference for logical right shifts of negative numbers:

```
// Arithmetic right shifts
8 (i8) >> 1 = 4
8 (i16) >> 1 = 4
8 (i32) >> 1 = 4
-8 (i8) >> 1 = -4
-8 (i16) >> 1 = -4
-8 (i32) >> 1 = -4

// Logical right shifts
8 (i8) >>> 1 = 4
8 (i16) >>> 1 = 4
8 (i32) >>> 1 = 4
-8 (i8) >>> 1 = 12
-8 (i16) >>> 1 = 32764
-8 (i32) >>> 1 = 2147483644
```

And since the only right shifts in the standard have code points or code units as their input, they must be positive.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/250#issuecomment-753961649

Received on Monday, 4 January 2021 13:01:26 UTC