Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!swrinde!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!uunet!brunix!gvr From: gvr@cs.brown.edu (George V. Reilly) Newsgroups: comp.lang.c Subject: Re: How to reverse bits... Message-ID: <47379@brunix.UUCP> Date: 15 Aug 90 06:07:26 GMT References: <2059@ux.acs.umn.edu> <1990Aug14.203212.16248@motcad.portal.com> <43975@apple.Apple.COM> Sender: news@brunix.UUCP Reply-To: gvr@cs.brown.edu (George V. Reilly) Organization: Brown University Department of Computer Science Lines: 13 In article <43975@apple.Apple.COM> austing@Apple.COM (Glenn L. Austin) writes: >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. > >How about "c ^= (char) -1"? How about ~, the built-in one's complement operator? Just mask off the high-order bits if you don't want them. output = ~input & 0xFF ________________ George V. Reilly gvr@cs.brown.edu uunet!brunix!gvr gvr@browncs.bitnet Box 1910, Brown U, Prov, RI 02912