IntPow Function |
Unit
QESBPCSMath
Declaration
Function IntPow(const Base: Extended; const Exponent: LongWord): Extended;
Description
Developed by Rory Daulton and used with permission. Last modified December 1998.
Implementation
function IntPow (const Base: Extended; const Exponent: LongWord): Extended; { Heart of Rory Daulton's IntPower: assumes valid parameters & non-negative exponent } asm fld1 { Result := 1 } cmp eax, 0 { eax := Exponent } jz @@3 fld Base jmp @@2 @@1: fmul ST, ST { X := Base * Base } @@2: shr eax,1 jnc @@1 fmul ST(1),ST { Result := Result * X } jnz @@1 fstp st { pop X from FPU stack } @@3: fwait End; |
|