Free web hosting services - JavaScript Programmer’s Reference See also: Associativity, Bit-field,Bitwise shift
Wednesday, October 10th, 2007JavaScript Programmer’s Reference See also: Associativity, Bit-field,Bitwise shift left (<<), Bitwise shift left then assign (<<=), Bitwise shift operator, Bitwise shift right and assign (>>=), Bitwise unsigned shift right (>>>), Bitwise unsigned shift right and assign (>>>=), Operator Precedence, Shift operator Cross-references: ECMA 262 edition 2 section 11.7.2 ECMA 262 edition 3 section 11.7.2 Bitwise shift right and assign (>>=) (Operator/assignment) Destructively bitwise rightwards shift the first of two operands. Availability: ECMAScript edition 2 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Netscape Enterprise Server 2.0 Opera 3.0 Property/method value type: Number primitive JavaScript syntax: -anOperand1 >>= anOperand2 anOperand1 A value to be shifted and assigned to Argument list: =”c2″>anOperand2 =”c3″>A distance to shift anOperand1 Bitwise shift rightwards the left operand by the number of bits in the right operand and assign the result to the left operand. This is functionally equivalent to the expression: anOperand1 = anOperand1 >> anOperand2; The bitwise shift right operator converts its left operand to a 32 bit integer and moves it rightwards by the number of bits indicated by the right operand. As the value is shifted rightwards, bits that roll out of the right end of the register are discarded. The left-hand end of the register containing the sign bit is duplicated to sign fill the value as it shifts. Shifting rightwards by 32 bits will fill the left operand with all zero or all one bits according to the value of the sign bit at the outset. Because the value is converted to an integer, any fractional part is discarded as the shift begins.