Difference between revisions of "Bitwise operation"

From Custom Mario Kart
Jump to navigation Jump to search
(Created page with "== Bitwise operations == In general there are 4 basic bitwise operations for binary numbers. In bitwise operations each bit is handled separately from all other bits. ; NOT : T...")
 
Line 1: Line 1:
 
== Bitwise operations ==
 
== Bitwise operations ==
  
In general there are 4 basic bitwise operations for binary numbers. In bitwise operations each bit is handled separately from all other bits.  
+
In general there are 4 basic bitwise operations for [[hexadecimal|binary numbers]]. In bitwise operations each bit is handled separately from all other bits.  
 
; NOT : This unary operator (=1 operand) is a sign operator and inverts each bit of the number.
 
; NOT : This unary operator (=1 operand) is a sign operator and inverts each bit of the number.
 
; AND : This is a binary operator (binary means here: 2 operands). A resulting bit is 1, if both operands are also 1.
 
; AND : This is a binary operator (binary means here: 2 operands). A resulting bit is 1, if both operands are also 1.
Line 26: Line 26:
 
== Operands ==
 
== Operands ==
  
Whenever bitwise operations are done, the operands are displayed as binary, octal or hexadecimal numbers, because they allow to see the bits directly. Please use hexadecimal numbers only in this wiki.
+
Whenever bitwise operations are done, the operands are displayed as binary, octal or hexadecimal numbers, because they allow to see the bits directly. Please use [[hexadecimal|hexadecimal numbers]] only in this wiki.

Revision as of 09:18, 16 May 2012

Bitwise operations

In general there are 4 basic bitwise operations for binary numbers. In bitwise operations each bit is handled separately from all other bits.

NOT
This unary operator (=1 operand) is a sign operator and inverts each bit of the number.
AND
This is a binary operator (binary means here: 2 operands). A resulting bit is 1, if both operands are also 1.
OR
This is a binary operator. A resulting bit is 1, if at least one of the operands is 1 (inclusive OR).
EOR or XOR
This is a binary operator. A resulting bit is 1, if exact one of the operands is is 1 (exclusive OR).
Bitwise Operations
A B NOT A
~A
NOT B
~B
A AND B
A & B
A OR B
A | B
A EOR B
A ^ B
0 0 1 1 0 0 0
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 1 1 0

Operands

Whenever bitwise operations are done, the operands are displayed as binary, octal or hexadecimal numbers, because they allow to see the bits directly. Please use hexadecimal numbers only in this wiki.