Skip to content

Comment on A Neat Bitwise Trick for Swapping Even and Odd Bitsparent

Comments

You're right, 8 bits is small enough to just store in a table.

This trick will work for any number of bits though. You might not want to use 2^64 entries in your table.

The question was an unsigned 8-bit input, not an arbitrary number.

And the "trick" given in the answer still depends on a fixed number of input bits, no matter if it's 8, 32, or 10^100.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.