Nęste
Forrige
Oversigt
JavaScript "Core Language" serie, Planche nr. 17
Kursus Indhold

Bitoperationer

Bitrvis Operatorer
Operator Usage Description

Bitwise AND

a & b

Returns a one in each bit position for which the corresponding bits of both operands are ones.

Bitwise OR

a | b

Returns a one in each bit position for which the corresponding bits of either or both operands are ones.

Bitwise XOR

a ^ b

Returns a one in each bit position for which the corresponding bits of either but not both operands are ones.

Bitwise NOT

~ a

Inverts the bits of its operand.

Left shift

a << b

Shifts a in binary representation b bits to left, shifting in zeros from the right.

Sign-propagating right shift

a >>
b

Shifts a in binary representation b bits to right, discarding bits shifted off.

Zero-fill right shift

a >>> b

Shifts a in binary representation b bits to the right, discarding bits shifted off, and shifting in zeros from the left.


© 1999 BLA*net - Leif E. Andersen, leander@blanet.dk