Path: chuka.playstation.co.uk!news From: Alex Herbert Newsgroups: scee.yaroze.freetalk.english Subject: Re: Square Root Date: Fri, 21 Aug 1998 19:31:21 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 47 Message-ID: <35DDBCF8.B018AE1E@ndirect.co.uk> References: <35DD914A.BBA25235@ndirect.co.uk> <35DD9B1E.3FEAA1E5@scee.sony.co.uk> <35DDAD74.CBCD107B@hinge.mistral.co.uk> Reply-To: aherbert@ndirect.co.uk NNTP-Posting-Host: dialin2-59.ndirect.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Craig Graham wrote: > Alternatively, if all you want is the length of a vector, > the manhattan distance approximation: > > inline short manhatan_distance(register unsigned short a, > register unsigned short b, > register unsigned short c) > { > register short t; > > if(a b > { > t=a; > a=b; > b=t; > } > > if(b c > { > t=b; > b=c; > c=t; > } > > if(a b > { > t=a; > a=b; > b=t; > } > > // t=a + (b>>2) + (c>>2); // faster lower accuracy > t=a + ((11*b)>>5) + (c>>2); // slower, more accurate > > return t; > } Thanks for that Craig. Not what I was looking for, but I think I'll find this very useful. Herbs