In JavaScript, whenever you perform a bitwise operation such as x << 2
, the 64-bit float representation gets converted to a 32-bit unsigned int before the shifting actually occurs. I am insterested in applying the shift to the actual, unaltered IEEE 754 bitwise representation.
How is that possible?
You might try converting the JSNumber to bytes/integers first and shifting the result yourself.
Using TypedArray stuff available in recent versions of major browsers:
After that you could shift the 32-bit-words in
w1
andw2
individually transferring upper 2 bits in lower word to lower 2 bits of upper word yourself.Endianess might be controlled on using second argument to
d.getUint32()
.Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
Just to ensure, comment of Bergi is recognized properly. All my code might be reduced to single line like that:
d[0]
andd[1]
are suitable for accessing contained 32-bit words, then.