🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #1199

Re: Bitwise EXOR

#1199
From: Peter Funk
Date: Mon, 01 Oct 1990 11:12
28 lines
1547 bytes
Herman.Stevens@p21701.f601.n292.z2.fidonet.org (Herman Stevens) writes:
[...]
hs> ......... I fail to see how I can do a bitwise EXOR, something you
hs> can easily write in C as :

hs>          tmpbuf[i] = inbuf[i]^key[kp]

hs> Can someone help me on this ?

Bit-Operations are usually coded in Modula-2 using the Type BITSET:
Assume : VAR b1, b2, b3 : BITSET;

	b3 := b1 * b2;     <-->     b3 <- b1 AND b2;
	b3 := b1 + b2;     <-->     b3 <- b1 OR  b2;
	b3 := b1 - b2;     <-->     b3 <- b1 AND NOT b2;
	b3 := b1 / b2;     <-->     b3 <- b1 XOR b2;

So your problem may be solved typing :
	     tmpbuf [i] := yourType (BITSET(inbuf [i]) / BITSET(key [kp]));
where 'yourType' is the element data type of 'tmpbuf'.

Gruss, Peter
-->
Peter Funk \\ ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
Work at home: Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)
>> PLEASE Don't send BIG mails (oversea) ! I've to pay for it : $0.3/kB
   Don't use the bang path of this news article for mails (They will bounce).
   Only the address 'pf@artcom0.north.de' will work. Thank You ! <<
Technical Details
Message-ID: <2299@artcom0.north.de>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!ira.uka.de!smurf!artcom0!pf
References: <303.27024D31@puddle.fidonet.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!ira.uka.de!smurf!artcom0!pf
From: pf@artcom0.north.de (Peter Funk)
Newsgroups: comp.lang.modula2
Subject: Re: Bitwise EXOR
Message-ID: <2299@artcom0.north.de>
Date: 1 Oct 90 11:12:14 GMT
References: <303.27024D31@puddle.fidonet.org>
Distribution: comp
Organization: ArtCom GmbH, Atelier f. Computergrafik, Bremen(FRG)
Lines: 28