Hi,

I read in the asm.js specs that:

As an example of the former, if we have an Int32Array 
<https://developer.mozilla.org/en-US/docs/JavaScript/Typed_arrays/Int32Array>
 view of the heap called HEAP32, then we can load the 32-bit integer at 
byte offset p:

HEAP32[p >> 2]|0

The shift converts the byte offset to a 32-bit element offset, and the 
bitwise coercion ensures that an out-of-bounds access is coerced from 
undefined back to an integer.

I understand that performing a bitwise operation will perform an integer 
coercion but why do we shift it 2 bits for a 32bit integer? Similarly, I 
notice that we shift it by 1 bit for a 16 bit short in cpp. Doesn't a shift 
of 2 bits divide the value of p by 4? 

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to