Bit - Bitwise and Shift binary operator

> (Data|State) Management and Processing > (Data Type|Data Structure) > Number, Numeric, Quantity > Bit - Binary Number

1 - About

Operator on bit.

See Reference/Operators/Bitwise_Operators

Bitwise binary operator may also be used as assignment operator

Advertising

3 - Type

  • the bitwise arithmetic operators (~, &, ^, and |)
  • and the shift operators (<<, >>, and >>>).

3.1 - Arithmetic

The bitwise arithmetic operators:

  • ~,
  • & (AND)
  • ^ (XOR)
  • and | OR

They are also Boolean operator.

3.1.1 - XOR (^)

The bitwise XOR expression follows the following rules:

0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0

3.1.2 - OR (|)

The bitwise OR expression follows the following rules:

0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1

Example:

console.log(6 | 2); // 6
console.log(8 | 1); // 9

Advertising

3.1.3 - AND (&)

0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1

3.2 - Shift

the shift operators (<<, >>, and >>>).

4 - Documentation / Reference

data/type/number/bit/operator.txt · Last modified: 2019/07/08 13:38 by gerardnico