News: 0000828486

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

[$] "Structural pattern matching" for Python, part 2

([Development] Sep 1, 2020 15:50 UTC (Tue) (jake))


[$] Sorry, this article is currently available to LWN suscribers only [https://lwn.net/subscribe/].

n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa);
n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc);
n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0);
n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00);
n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000);

-- C code which reverses the bits in a word.