Very nice! My solution was also four ops (discounting the !!), but yours is more elegant and doesn't require common-subexpression elimination. Yours: (a-b)&(b-a)&b Mine: (a^b)&-(a^b)&b Now what possible use could this be? -tom On Tue, Jan 14, 2014 at 3:33 PM, Mike Speciner <ms@alum.mit.edu> wrote:
I don't know if this is the fastest but, ...
On 2014-01-14 16:26, Tom Rokicki wrote:
For an unsigned 64-bit integer, define br(x) to be the "bit reversal" of x: bit positions 0 and 63 are swapped, 1 and 62 are swapped, and so on.
What's the fastest way in generic C code to compute
br(a) < br(b)
[Don't spoil this if you've seen it already, please.]
-tom
. . . . . . . . .
!!((a-b)&(b-a)&b)
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
-- -- http://cube20.org/ -- http://golly.sf.net/ --