User Tools

Site Tools


chess:programming:lsb_least_significant_bit

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
chess:programming:lsb_least_significant_bit [2021/10/30 12:05] – [Using de Bruijn] peterchess:programming:lsb_least_significant_bit [2021/10/30 13:11] (current) peter
Line 98: Line 98:
 ---- ----
  
-===== Using de Bruijn for 32-bit ===== 
- 
-u32 msbDeBruijn32(u32 v) 
-{ 
-    static const int MultiplyDeBruijnBitPosition[32] = 
-    { 
-        0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 
-        8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 
-    }; 
- 
-    v |= v >> 1; // first round down to one less than a power of 2 
-    v |= v >> 2; 
-    v |= v >> 4; 
-    v |= v >> 8; 
-    v |= v >> 16; 
- 
-    return MultiplyDeBruijnBitPosition[( u32 )( v * 0x07C4ACDDU ) >> 27]; 
-} 
-</code> 
- 
----- 
  
 ===== Using Logs ===== ===== Using Logs =====
Line 209: Line 188:
  
 ===== References ===== ===== References =====
- 
-https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64?redirectedfrom=MSDN&view=msvc-160 
  
 http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
Line 217: Line 194:
  
 https://en.wikipedia.org/wiki/Bit_numbering https://en.wikipedia.org/wiki/Bit_numbering
 +
 +https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64?redirectedfrom=MSDN&view=msvc-160
chess/programming/lsb_least_significant_bit.1635595509.txt.gz · Last modified: 2021/10/30 12:05 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki