I tested several 32-bit reversors for speed. Arndt32BitReverseA: 0.598 like Freed but without explicit constants Arndt32BitReverseB: 0.492 uses 31=5*3+1+5*3, 32=31+1 Freed32BitReverse: 0.484 uses 32,16,8,4,2,1 WDS32BitReverseA: 0.526 uses 32=27+5; 5 handled using multiply/mask tricks WDS32BitReverseB: 0.500 uses 32=27+5; 5 handled via 32-byte table lookup The winner is the comparatively boring: uint32 Freed32BitReverse(uint32 v){ //Edwin Freed in Dr. Dobb's Journal 1983. v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1); // swap odd and even bits v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2); // swap consecutive pairs v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4); // swap nybbles v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8); // swap bytes v = ( v >> 16 ) | ( v << 16); //swap 2-byte long pairs return(v); } -- Warren D. Smith http://RangeVoting.org <-- add your endorsement (by clicking "endorse" as 1st step)