🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6161

XOR-chaining

#6161
From: Pertti Lehtinen
Date: Thu, 12 Jan 1989 14:17
37 lines
1679 bytes
From article <4061@hubcap.UUCP>, by mcvax!etive.ed.ac.uk!gvw@uunet.UU.NET (MOBY):
> I'm looking for "clever" programming tricks.  For example,
> consider the following problem:
> 
>     Given a computer word W in which one or more bits are set,
>     change the lowest set bit from 1 to 0, and set the corresponding
>     bit in another word B to 1.  Eg. if the input is W = 0x0860,
>     return W' = 0x0840 and B' = 0x0020.

	This can be also done by:

		B' = (~W+1)&W
		W' = W^B

> I would like to hear about similar tricks that people have invented/
> discovered.  In particular, I'm looking for fast ways to count the
> number of 1 bits in a word (on machines that don't have this as a
> machine instruction :-), and trying to find a description of a
> mythical technique for creating doubly-linked lists using single
> pointers and XOR operations.
> 

	About XOR-chaining there is article in 
	Doctor Dobbs Journal, June, 87 and also
	September 87.

	Later article discusses about handling of binary trees
	without stacks (Using XOR-technicues).


				Yours
				Pertti Lehtinen
				pl@tut.fi
pl@tut.fi				! All opinions expressed above
Pertti Lehtinen				! are preliminary and
Tampere University of Technology	! in subject to change
Software Systems Laboratory		! without any further notice.
Technical Details
Message-ID: <5759@etana.tut.fi>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!enea!kth!draken!tut!kaarne!pl

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!enea!kth!draken!tut!kaarne!pl
From: pl@kaarne.tut.fi (Pertti Lehtinen)
Newsgroups: comp.lang.misc
Subject: XOR-chaining
Message-ID: <5759@etana.tut.fi>
Date: 12 Jan 89 14:17:54 GMT
Sender: News@tut.fi
Reply-To: pl@kaarne.tut.fi.UUCP ()
Organization: Tampere University of Technology, Finland
Lines: 37