TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Russ Parks
from: Patrick Annette
date: 1995-12-20 18:28:04
subject: power() for VirtualPasca

Quoting Russ Parks to Patrick Annette in a message dated 12/18

RP>  Here's some old TurboPascal 6.0 code I've been using for 
RP> quite a while...it's a bit shorter than what you have 
RP> (maybe faster?).
 
[...]

Russ, thanks for the power function code.  It compiled in Virtual Pascal
with no problem; only change needed was "var OldCw,TempCw:SmallWord."

Some of my code is just there to make the function work like IBM's pow()
function in CSET++ FirstStep.   Return zero if both base and exponent
are zero, for example.  

But beyond that, your code is definitely shorter, avoiding the 
FPREM complications.  This is supposed to be necessary in order to limit
the argument of F2XM1 to the range [-0.5, +0.5], but after trying your
code, I'm not sure it's needed.  That's the trouble with using a
cookbook approach, you only *think* you understand!  Now I'll have to
work through and see if it's really needed.  If not, there will
definitely be some time saved.

(later) Just did some experiments with the F2XM1 and it looks to me like
it works fine over the range [-1.0, 1.0] running on a 486DX.  If that's
true on a '387 also, my function will become practically identical to
yours.  I'd like to make sure it will work with any OS/2 system FPU. 
You don't happen to know a good reference on this, do you?

Your example also encouraged me to convert the function to use the
assembler directive.  That should also save some time, since it
eliminates the code VP generates for 'begin' and 'end' statements.

thanks again,

Patrick

---
 X KWQ/2 1.2i X I'm not young enough to know everything anymore...
--- Maximus/2 2.02
* Origin: OS/2 Online * Auburn, WA * 206-351-5998 * (1:343/212)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515
SEEN-BY: 712/517 628 713/888 800/1 7877/2809
@PATH: 343/212 800 1 138/103 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.