Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: Bit Switching - How? Summary: Not like this. Message-ID: <1002@philmds.UUCP> Date: 13 Apr 89 21:00:15 GMT References: <18944@adm.BRL.MIL> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 19 In article <18944@adm.BRL.MIL> rbj@dsys.icst.nbs.gov (Root Boy Jim) writes: [] |void bit flip(x,y,mask) int *x, *y; /* mask can be more than one bit */ |{ | int z = (x ^ y) & mask; /* difference of interesting bits */ | if (z) /* some bits differ */ | x ^= z, y^= z; /* flip those that do */ |} What is this piece of code supposed to do? Since its return type is 'void', one would expect it to dereference its pointer arguments; it doesn't (so in fact it is a pure function, and since it returns nothing, a no-op 8-). Well, probably the x, y in the function body should read *x, *y; and what about renaming 'void bit flip' to 'void bitflip' ? Makes my compiler happier. B.T.W. am I the first one to spot this? Leo.