Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!hp4nl!sci.kun.nl!atcmpe!jc From: jc@atcmp.nl (Jan Christiaan van Winkel) Newsgroups: comp.lang.c Subject: flipping bits (was: Re: How to reverse bits...) Message-ID: <652@atcmpe.atcmp.nl> Date: 15 Aug 90 07:38:08 GMT References: <1990Aug14.233308.27889@caen.engin.umich.edu> Organization: AT Computing, Nijmegen, The Netherlands Lines: 22 From article <1990Aug14.233308.27889@caen.engin.umich.edu>, by jal@acc (John Lauro): ) 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. ) ) How about: (assuming 8 bit char c) ) c=255-c; or ) c^=255; Why make specifications about the charcter's size in bits? There is an operator in C that is perfectly suited to do the job without having to specify the number of bits to be flipped: c = ~c; which works for chars, ints, longs, .... JC -- ___ __ ____________________________________________________________________ |/ \ Jan Christiaan van Winkel Tel: +31 80 566880 jc@atcmp.nl | AT Computing P.O. Box 1428 6501 BK Nijmegen The Netherlands __/ \__/ ____________________________________________________________________