Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function IntPower(X: Real; I: LongInt): Real;
- Var
- Y: LongInt;
- Res: Real;
- Begin
- Y:= Abs(I);
- Res:= 1.0;
- While Y > 0 Do Begin
- While Not Odd(Y) Do Begin
- Y:= Y Shr 1;
- X:= X * X
- End;
- Dec(Y);
- Res:= Res * X;
- End;
- If I < 0 Then Res:= 1.0 / Res;
- IntPower:= Res;
- End;
- Function Power(B, E: Real): Real;
- Begin
- If E = 0.0 Then
- Power:= 1.0
- Else If (B = 0.0) And (E > 0.0) Then
- Power:= 0.0
- Else If (Frac(E) = 0.0) And (Abs(E) <= MaxLongInt) Then
- Power:= IntPower(B, LongInt(Trunc(E)))
- Else
- Power:= Exp(E * Ln(B));
- End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement