🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3267

Re: XOR function

#3267
From: Bengt-Inge Dalenback
Date: Mon, 12 Feb 1996 10:46
28 lines
1873 bytes
In article <1996Feb8.114044.15072@ucl.ac.uk> Chris Austin,
zcaccau@cs.ucl.ac.uk writes:
>Is there an XOR function in Topspeed Modula-2 V3.something.  I want to be
>able to XOR either 2 cardinals or 2 BITSETs, so if there isn't a function,
>what is the best way to implement it.  I need speed, not simplicity, as this
>is for graphics routines.
>

I just yesterday needed that to create a XOR checksum required for the
Windows "placeable" Meta-file header!

Low-level tricks like that can be done using SET operations. XOR is "/"
which means for A, B and C CARDINALs:

  "C = A XOR B" <=> C := CARDINAL( BITSET(A) / BITSET(B) );

Check out the "TopSpeed Language Tutorial" on SETs in case I remembered
it wrong. TopSpeed also has a "bitwise boolean operator" pragma that
sometimes
can be handy but which of course is nonportable.

.......................................................................
Bengt-Inge Dalenback
at:                                     and:
   Department of Applied Acoustics         CATT
   Chalmers University of Technology       (Software for room acoustic 
   Gothenburg, SWEDEN                      prediction and auralization)
   e-mail: bid@ta.chalmers.se              e-mail: catt@netg.se
Technical Details
Message-ID: <4fn5qu$ejm@nyheter.chalmers.se>
Path: arc1-ca.pugleaf.net!g0-mac7.ta.chalmers.se!bid
References: <1996Feb8.114044.15072@ucl.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!g0-mac7.ta.chalmers.se!bid
From: Bengt-Inge Dalenback <bid@ta.chalmers.se>
Newsgroups: comp.lang.modula2
Subject: Re: XOR function
Date: 12 Feb 1996 10:46:54 GMT
Organization: CATT & Dep. of Applied Acoustics, Chalmers
Distribution: world
Message-ID: <4fn5qu$ejm@nyheter.chalmers.se>
References: <1996Feb8.114044.15072@ucl.ac.uk>
NNTP-Posting-Host: g0-mac7.ta.chalmers.se
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: Nuntius 2.0.1_68K
X-XXMessage-ID: <AD44D99ED401B84A@g0-mac7.ta.chalmers.se>
X-XXDate: Mon, 12 Feb 1996 10:48:46 GMT