chess:programming:lsb_least_significant_bit
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
chess:programming:lsb_least_significant_bit [2021/10/30 12:05] – [Using de Bruijn] peter | chess: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]; | ||
- | } | ||
- | </ | ||
- | |||
- | ---- | ||
===== Using Logs ===== | ===== Using Logs ===== | ||
Line 209: | Line 188: | ||
===== References ===== | ===== References ===== | ||
- | |||
- | https:// | ||
http:// | http:// | ||
Line 217: | Line 194: | ||
https:// | https:// | ||
+ | |||
+ | https:// |
chess/programming/lsb_least_significant_bit.1635595509.txt.gz · Last modified: 2021/10/30 12:05 by peter