You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Try replacing:




    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!


Avatar for Gordon @Gordon started