Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!rutgers!mephisto!prism!sun13!VSSERV.SCRI.FSU.EDU!mayne From: mayne@VSSERV.SCRI.FSU.EDU (William (Bill) Mayne) Newsgroups: comp.lang.c Subject: Re: How to reverse bits... Message-ID: <401@sun13.scri.fsu.edu> Date: 15 Aug 90 16:32:29 GMT References: <2059@ux.acs.umn.edu> <1990Aug14.203212.16248@motcad.portal.com> Sender: news@sun13.scri.fsu.edu Organization: SCRI, Florida State University Lines: 20 In article <1990Aug14.203212.16248@motcad.portal.com> jtc@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.