Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.freetalk.english Subject: Re: Square Root Date: Fri, 21 Aug 1998 17:06:54 +0100 Organization: Sony Computer Entertainment Europe Lines: 29 Message-ID: <35DD9B1E.3FEAA1E5@scee.sony.co.uk> References: <35DD914A.BBA25235@ndirect.co.uk> NNTP-Posting-Host: mailgate.scee.sony.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5b1 [en] (Win95; I) X-Accept-Language: en > It works fine, but does anyone know a better way to find the square root > of any u_long? From the graphics algorithms FAQ... void sqrt(u_long square) { long r, s, t, z; r = 0; z = square; for(t = 0x40000000; t; t >>=2) { s = r + t; if(s <= square) { square -= s; r = s + t; } r >>= 1; } return r; } -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe When their numbers dwindled from 50 to 8, the dwarfs began to suspect "Hungry"