News for hackers. Stuff that matters.
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?
Re:Bit Twiddling Hacks (2005) by Kristine1975 on Monday July 04, 2016 @04:12AM (#12029410)
Re:Bit Twiddling Hacks (2005) by emanuelev on Monday July 04, 2016 @03:02AM (#12029249)
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