Article View: comp.lang.modula2
Article #1192Re: Bitwise EXOR
From: Preston Briggs
Date: Sun, 30 Sep 1990 13:37
Date: Sun, 30 Sep 1990 13:37
36 lines
1466 bytes
1466 bytes
In article <1230@cluster.cs.su.oz.au> steve@cluster.cs.su.oz (Stephen Russell) writes:
>Herman Stevens asks:
>>I fail to see how I can do a bitwise EXOR, something you
>>can easily write in C as :
>>
>> tmpbuf[i] = inbuf[i]^key[kp]
>>
>>Can someone help me on this ?
>
>It ain't as simple as in C (but then neither are bit-ands and ors). Try
>using the symmetric set difference operator by casting. Something
>like this might work:
>
> tmpbuf[i] := CARDINAL(BITSET(inbuf[i]) / BITSET(key[kp]))
Well, if you want to fiddle bits, use BITSETs in the first place.
Then, assuming you've declared all your variables as arrays
of BITSET, you simply write
tmpbuf[i] := inbuf[i] / key[kp]
I think "symmetric set difference" is a rather unhelpful name,
but perhaps it's more common in Europe.
Note also that the BITSET idea is handy for testing and setting
particular bits.
IF 2 IN key[kp] THEN ...
or
tmpbuf[i] := key[kp] + {5, 7}
--
Preston Briggs looking for the great leap forward
preston@titan.rice.edu
Technical Details
Message-ID:
<1990Sep30.133717.7936@rice.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!rice!titan.rice.edu!prestonReferences:
<1230@cluster.cs.su.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!rice!titan.rice.edu!preston From: preston@titan.rice.edu (Preston Briggs) Newsgroups: comp.lang.modula2 Subject: Re: Bitwise EXOR Message-ID: <1990Sep30.133717.7936@rice.edu> Date: 30 Sep 90 13:37:17 GMT References: <1230@cluster.cs.su.oz.au> Sender: news@rice.edu (News) Organization: Rice University, Houston Lines: 36