I have a piece of Javascript code I\'m trying to understand
// read big-endian (network byte order) 32-bit float
readFloat32 = function(data, offset) {
v
From http://ecma262-5.com/ELS5_HTML.htm
11.7 Bitwise Shift Operators
ShiftExpression : AdditiveExpression ShiftExpression << AdditiveExpression ShiftExpression >> AdditiveExpression ShiftExpression >>> AdditiveExpression
11.7.1 The Left Shift Operator ( << ) Performs a bitwise left shift operation on the left operand by the amount specified by the right operand. The production ShiftExpression : ShiftExpression << AdditiveExpression is evaluated as follows:
Let lref be the result of evaluating ShiftExpression. Let lval be GetValue(lref). Let rref be the result of evaluating AdditiveExpression. Let rval be GetValue(rref). Let lnum be ToInt32(lval). Let rnum be ToUint32(rval). Let shiftCount be the result of masking out all but the least significant 5 bits of rnum, that is, compute rnum & 0x1F. Return the result of left shifting lnum by shiftCount bits. The result is a signed 32-bit integer.
11.7.2 The Signed Right Shift Operator ( >> ) Performs a sign-filling bitwise right shift operation on the left operand by the amount specified by the right operand.
The production ShiftExpression : ShiftExpression >> AdditiveExpression is evaluated as follows:
Let lref be the result of evaluating ShiftExpression. Let lval be GetValue(lref). Let rref be the result of evaluating AdditiveExpression. Let rval be GetValue(rref). Let lnum be ToInt32(lval). Let rnum be ToUint32(rval). Let shiftCount be the result of masking out all but the least significant 5 bits of rnum, that is, compute rnum & 0x1F. Return the result of performing a sign-extending right shift of lnum by shiftCount bits. The most significant bit is propagated. The result is a signed 32-bit integer.
These are bit operators. Have a look at this link: Bitwise Operators
It is an arithmetic shift
shift a by b bits to the left (padding with zeros)
a << b
shift a by b bits to the right (copying the sign bit)
a >> b