Changes

Jump to: navigation, search

Bitwise Operations

145 bytes added, 14:23, 18 September 2023
OR
|Mask ||bgcolor="yellow"|1||bgcolor="yellow"|1||bgcolor="yellow"|1||bgcolor="yellow"|1||0||0||0||0
|-align="center"
|Output||bgcolor="yellow"|1||bgcolor="yellow"|1||bgcolor="yellow"|1||bgcolor="yellow"|1||bgcolor="yellow"|10||bgcolor="yellow"|01||bgcolor="yellow"|10||bgcolor="yellow"|01
|}
Therefore the bitwise ''AND'' is used to '''clears bits''' to a value of 0.
For example, bits 0-:3 can be cleared to 0 while preserving the remaining bits in a byte by ANDing a mask of 11110000 (0xF0):
{|cellspacing="0" cellpadding="5" border="1"
|Output||bgcolor="yellow"|0||bgcolor="yellow"|1||bgcolor="yellow"|0||bgcolor="yellow"|1||bgcolor="yellow"|0||bgcolor="yellow"|0||bgcolor="yellow"|0||bgcolor="yellow"|0
|}
 
=== XOR ===
A rotate-left by 1 bit performed on a byte will move bit 0 to bit 1, bit 1 to bit 2, bit 2 to bit 3, and so forth. Bit 7 will move to bit 0.
 
Note that in some processors, a status register bit is included in the rotation, allowing rotates to be strung together in multi-byte sequences.
=== Shift ===

Navigation menu