Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: glen herrmannsfeldt Newsgroups: comp.programming,comp.lang.pl1 Subject: Re: calculating the power of a fixed point Date: Fri, 23 Sep 2011 17:07:55 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 37 Message-ID: References: <2d2836aa-2443-4e56-9fef-d38e12c60dcf@z41g2000yqb.googlegroups.com> <881091c4-8dd2-47a1-b81f-f98e68a9bb12@s2g2000prm.googlegroups.com> NNTP-Posting-Host: +XZUpqwGg6W4jfUjJWhQTA.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: tin/1.9.6-20100522 ("Lochruan") (UNIX) (Linux/2.6.32-5-amd64 (x86_64)) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.programming:855 comp.lang.pl1:595 In comp.lang.pl1 Robin Vowels wrote: (snip, I wrote) >> Fortran and PL/I explicitly allow for an integer second argument >> with integer or real (or complex) first argument. >> One could imagine, for example, >> with a FIXED BINARY(31,1) second argument a power routine that >> computed the square root of the first argument in cases where the >> least significant bit was one. > I assume that you mean when all the other bits are zero. No, I assumed that one would then multiply by the power computed with the usual multplication algorithm from the other bits. > In any case, a power routine would not be used. Newton's > method or some such would be used for square root. One could extend it for other negative powers of two with additional calls to the square root routine. >> have never known such an implementation. Reminds me of a chapter in "Feynman Lectures on Physics" explaining how the first log tables would have been computed. (I don't know that it is historically accurate, but it seems right.) First you take the square root of 10, or 10**0.5. Now take the square root of that, for 10**0.25. After 10 such square roots you have powers of 10 down to 1/1024. By multiplying, you can make a table of all powers of 10 from 1/1024 to 1023/1024 in 1/1024 steps. Inverting the table and interpolating, you make a log10 table. The chapter then continues on to derive imaginary powers of 10. -- glen