User Tools

Site Tools


chess:programming:bit_operations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
chess:programming:bit_operations [2021/11/05 09:51] peterchess:programming:bit_operations [2021/11/05 09:55] (current) peter
Line 28: Line 28:
 Apply an odd mask against it: Apply an odd mask against it:
  
 +<code>
 00101101011001010111000110001001   &    (n) 00101101011001010111000110001001   &    (n)
 01010101010101010101010101010101        (0x55555555) 01010101010101010101010101010101        (0x55555555)
 ———————————————————————————————— ————————————————————————————————
 00000000000101000100000101000100        (Contains all odd bits) 00000000000101000100000101000100        (Contains all odd bits)
 +</code> 
  
 <WRAP info> <WRAP info>
 **NOTE:**  Use Masks. **NOTE:**  Use Masks.
  
-  * 0xAAAAAAAA 1010 1010 1010 1010 1010 1010 1010 1010 +  * Mask **0xAAAAAAAA** has all its even bits set. 
-  * 0x55555555 = 0101 0101 0101 0101 0101 0101 0101 0101+    * Its bitwise AND with a number will separate out the even bits. 
 +    * 1010 1010 1010 1010 1010 1010 1010 1010 
 + 
 +  * Mask **0x55555555** has all its odd bits set. 
 +    * Its bitwise AND with a number will separate out the odd bits. 
 +    * 1010 1010 1010 1010 1010 1010 1010 1010
  
 </WRAP> </WRAP>
chess/programming/bit_operations.1636105916.txt.gz · Last modified: 2021/11/05 09:51 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki