Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: zakath on September 01, 2008, 04:59:06 pm

Title: Exponential Function
Post by: zakath on September 01, 2008, 04:59:06 pm
Script Name: Exp
Script Description: Calculates the Exponential Function
Original Author(s): Zakath
Core Version: 2.6.3
Code:
Code: [Select]

const
EXPRECISION = 25; // the higher number the better precision and the more calculations(cputime)

function Exp(Exponent: double): double;
var
    i, j: integer;
    numerator, denominator: double;
begin
    Result := 1;


    for i:= 1 to EXPPRECISION do
    begin
        denominator := 1;
        numerator := 1;
        for j:= 1 to i do
        begin
            denominator := denominator * j;
            numerator := numerator * Exponent;
        end;
        Result := Result + numerator/denominator;
    end;
end;