Re:Bit Twiddling Hacks (2005)
by mungoman2 on Sunday July 03, 2016 @05:34PM
(#12027719)
There are some neat tricks there about interleaving bits from two operands. But what about from 3?
[ Parent
| on HN ]
Re:Bit Twiddling Hacks (2005)
by Kristine1975 on Monday July 04, 2016 @04:12AM
(#12029410)
Maybe this helps: http://www.forceflow.be/2013/10/07/morton-encodingdecoding-t...
If you are referring to Morton's interleaving, then it's quite simple. You can compute the third operand's code and OR it with the others using the appropriate shift. Something like: (z << 2) | (y << 1) | x