Bit hacking and modulo operation
While reading this: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv I came to the phrase: The last step, which involves modulus division by 2^10 - 1, has the effect of merging together each set of 10 bits (from positions 0-9, 10-19, 20-29, ...) in the 64-bit value. (it is about reversing the bits in a number)... so I did some calculations: reverted = (input * 0x0202020202ULL & 0x010884422010ULL) % 1023; b = 74 : 01001010 b * 0x0202020202 : 1000000010000000100000001000000010 = 9494949494 :01001010010010100100101001001010010010100 & 10884422010 :100001000100001000100
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.