Path: utzoo!yunexus!ists!helios.physics.utoronto.ca!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!tut.cis.ohio-state.edu!n8emr!uncle!oink!jep From: jep@oink.UUCP (James E. Prior) Newsgroups: comp.graphics Subject: Re: Integral Square Root Message-ID: <52@oink.UUCP> Date: 31 Dec 89 17:16:46 GMT Article-I.D.: oink.52 References: <9170@cbmvax.commodore.com> Reply-To: jep@oink.UUCP (James E. Prior) Organization: Random Prime Research Institute Columbus, Ohio Lines: 28 In article <9170@cbmvax.commodore.com> mitchell@cbmvax.UUCP (Fred Mitchell - PA) writes: >... > for (i = 15, r = 0; i >= 0; --i) > if ( (rb = r+(b=1< r += b; > return (ULONG) r; >... Beware, C doesn't guarantee the order of evaluation. Fred's code will work on some compilers, but not on others. The following code fragment should overcome that particular problem. for (i=15,r=0;i>=0;--i) if ((rb=r+(b=1<=0;i--,b>>=1) { rb=r+b; if (rb*rb<=n) r+=b; return (ULONG)r; -- Jim Prior jep@oink osu-cis!n8emr!oink!jep N8KSM