The >>> operator is an unsigned shift, whereas >> is a signed shift.
The issue is that when the top bit of a number gets set, signed shift shifts in extra 1s as you shift right (so -8>>1 == -4 like you'd expect) - unsigned shift always shifts in 0.
Having said that, there appears to be a bug in Espruino that causes Uint32Array to return negative numbers (which is why this is a problem). I've had it down as something to fix - however it works when compiled on the PC, but not when running on the device!
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Try replacing:
with:
The
>>>
operator is an unsigned shift, whereas>>
is a signed shift.The issue is that when the top bit of a number gets set, signed shift shifts in extra 1s as you shift right (so
-8>>1 == -4
like you'd expect) - unsigned shift always shifts in 0.Having said that, there appears to be a bug in Espruino that causes Uint32Array to return negative numbers (which is why this is a problem). I've had it down as something to fix - however it works when compiled on the PC, but not when running on the device!