Path: chuka.playstation.co.uk!news From: Philip Gooch Newsgroups: scee.yaroze.beginners Subject: Re: Clever bit manipulation routines? Date: Fri, 24 Jul 1998 09:47:32 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 27 Message-ID: <35B84A24.939EB9F8@easynet.co.uk> References: <35B79502.BC7489D6@nospam.easynet.co.uk> <35B7BB71.D869219@compuserve.com> NNTP-Posting-Host: 193.131.140.246 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [en] (Win95; I) Nick Slaven wrote: > how about the limitRange macro (tho its not bit manipulation) > like this > > limitRange(gPlayer.turningAngle,-45,45); > > its defined in libps.h & is coded as follows. > > #define limitRange(x, l, h) ((x)=((x)<(l)?(l):(x)>(h)?(h):(x))) > > The A=B?C:D; construct you find here, (if you're familiar with it > ignore the rest) takes the argument in B and if it is nonzero (ie true) > sticks the value of C in A, if B is zero (ie false) the value of D is > placed in A. B can be a single variable or any logical expression (like > (gPlayer.turningAngle<-45) for instance) > > cheers > > Nick (S) That'll do nicely! I should have spotted that myself. Cheers. Phil