chess:programming:msb_most_significant_bit
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
chess:programming:msb_most_significant_bit [2021/10/30 12:21] – [Using de Bruijn for 32-bit] peter | chess:programming:msb_most_significant_bit [2021/10/30 12:29] (current) – [Using Built-in for GCC] peter | ||
---|---|---|---|
Line 41: | Line 41: | ||
<code cpp> | <code cpp> | ||
- | __builtin_clz | + | unsigned BSR64(uint64_t x) |
- | __builtin_clzl | + | { |
+ | return 63-__builtin_clzll(x); | ||
+ | } | ||
</ | </ | ||
<WRAP info> | <WRAP info> | ||
- | **NOTE: | + | **NOTE: |
+ | |||
+ | | ||
+ | | ||
+ | | ||
- | * See https:// | + | |
+ | | ||
</ | </ | ||
Line 138: | Line 146: | ||
<code cpp> | <code cpp> | ||
#include < | #include < | ||
+ | unsigned BSR32(unsigned long x) | ||
+ | { | ||
+ | bsr_idx_t idx; | ||
+ | _BitScanReverse(& | ||
+ | return idx; | ||
+ | } | ||
- | unsigned | + | unsigned |
- | unsigned long * Index, | + | { |
- | unsigned long Mask | + | |
- | ); | + | |
- | unsigned char _BitScanForward64( | + | |
- | | + | } |
- | unsigned __int64 Mask | + | |
- | ); | + | |
</ | </ | ||
chess/programming/msb_most_significant_bit.1635596481.txt.gz · Last modified: 2021/10/30 12:21 by peter