Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!bloom-beacon!athena.mit.edu!tuna From: tuna@athena.mit.edu (Kirk 'UhOh' Johnson) Newsgroups: comp.graphics Subject: Re: APPROXIMATING SQUARE_ROOT Message-ID: <1989Nov28.171915.835@athena.mit.edu> Date: 28 Nov 89 17:19:15 GMT References: <1989Oct26.155201.5087@rpi.edu> <14397@well.UUCP> <367@oscsuna.osc.edu> <63127@psuecl.bitnet> <542@xdos.UUCP> Sender: root@athena.mit.edu (Wizard A. Root) Reply-To: tuna@athena.mit.edu (Kirk 'UhOh' Johnson) Distribution: usa Organization: Massachusetts Institute of Technology Lines: 26 In article <542@xdos.UUCP> doug@xdos.UUCP (Doug Merritt) writes: >In article <63127@psuecl.bitnet> c9h@psuecl.bitnet writes: >>Even with floating point numbers, and divide by 2 can be extremely fast >>if coded such that the exponent is simply decremented by one. I would hope >>that many compilers do this optimization automatically, but I don't know. > >This breaks when the number is not an exact power of two, because you're >not doing anything to the mantissa. So there'd better not be any compilers >that do this. > untrue. consider a number N of the form: E N = M * 2 clearly, N/2 _can_ be obtained by simply decrementing E, for: E-1 N/2 = M * 2 kirk ------------------------------------------------------------------------------- `For a long time I felt without kirk johnson style and grace, wearing shoes Brought to you by Super Global Mega Corp .com