title: How to bit scan forward and reverse a __uint128_t (128bit)?
body: <p>I have done with bit scan forward/reverse a 64bit using DeBruijn algorithm but cannot archive 128bit, __uint128_t. Is there any solution? Thanks in advance!</p>
  
  <p>FYI code for bit scan forward/reverse a 64bit using DeBruijn algorithm:</p>
  
  <pre><code>constexpr std::uint32_t
  bitScanForward&lt;std::uint64_t&gt;(std::uint64_t n) noexcept {
      constexpr std::uint32_t seq[] = {
          0,  47, 1,  56, 48, 27, 2,  60, 57, 49, 41, 37, 28, 16, 3,  61,
          54, 58, 35, 52, 50, 42, 21, 44, 38, 32, 29, 23, 17, 11, 4,  62,
          46, 55, 26, 59, 40, 36, 15, 53, 34, 51, 20, 43, 31, 22, 10, 45,
          25, 39, 14, 33, 19, 30, 9,  24, 13, 18, 8,  12, 7,  6,  5,  63};
      return seq[((n ^ (n - 1)) * 0x03f79d71b4cb0a89ULL) &gt;&gt; 58];
  }
  
  constexpr std::uint32_t
  bitScanReverse&lt;std::uint64_t&gt;(std::uint64_t n) noexcept {
      n |= n &gt;&gt; 1;
      n |= n &gt;&gt; 2;
      n |= n &gt;&gt; 4;
      n |= n &gt;&gt; 8;
      n |= n &gt;&gt; 16;
      n |= n &gt;&gt; 32;
      constexpr std::uint32_t seq[] = {
          0,  47, 1,  56, 48, 27, 2,  60, 57, 49, 41, 37, 28, 16, 3,  61,
          54, 58, 35, 52, 50, 42, 21, 44, 38, 32, 29, 23, 17, 11, 4,  62,
          46, 55, 26, 59, 40, 36, 15, 53, 34, 51, 20, 43, 31, 22, 10, 45,
          25, 39, 14, 33, 19, 30, 9,  24, 13, 18, 8,  12, 7,  6,  5,  63};
      return seq[(n * 0x03f79d71b4cb0a89ULL) &gt;&gt; 58];
  }
  </code></pre>