What does the following Javascript statement do to a
?
a >>>= b;
The increment operator ( ++ ) increments (adds one to) its operand and returns the value before or after the increment, depending on where the operator is placed.
The ! symbol is used to indicate whether the expression defined is false or not. For example, !( 5==4) would return true , since 5 is not equal to 4. The equivalent in English would be not .
JavaScript includes various categories of operators: Arithmetic operators, Comparison operators, Logical operators, Assignment operators, Conditional operators.
JavaScript Operators are as rich as what you'd expect from any modern language. There are four categories: arithmetic, comparison, assignment, and logical.
It does the same thing as this:
a = a >>> b;
Except that a
is only evaluated once (which has observable difference if its evaluation involves any side effects).
And >>>
is unsigned (logical) right shift.
I right shifts the value in a the number of bits specified by the value in b, without maintaining the sign.
It's like the >>= operator that rights shifts a value, only that one does not change the sign of the number.
Example:
var a = -1;
// a now contains -1, or 11111111 11111111 11111111 11111111 binary
var b = 1;
a >>>= b;
// a now contains 2147483647, or 01111111 11111111 11111111 11111111 binary.
It's a bitwise operator called zero-fill right shift. It will shift the binary representation of a
to the right by b
places, and replace the empty items with zeros. Then the result will be assigned to a
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With