How to reverse bits...

William Bill Mayne mayne at VSSERV.SCRI.FSU.EDU
Thu Aug 16 02:32:29 AEST 1990


In article <1990Aug14.203212.16248 at motcad.portal.com> jtc at motcad.portal.com (J.T. Conklin) writes:
>
>Another useful table is one that flips the bits 1-for-0,0-for-1.  This
>is useful for inverting an image.
>
>	--jtc
>
On all the hardware I've seen inverting all the bits is done more
cleanly, compactly, and probably quickly by bitwise exclusive or
with a mask of all 1s. 

Returning to the bit reversal question, how would you or others
construct the table of reversed bit bytes? In several assembly
languages I've used the preprocessor would make this quite easy.
In C I think I'd have to resort to either computing the table
at run time or having a program compute it and write out an
#include file to define it. You may infer from this that I have
been somewhat spoiled and am no great fan of the very limited
preprocessor facilities provided by C, though I really like the
language.



More information about the Comp.lang.c mailing list