Fractional Exponents in Delphi


[ Post Followup ] [ Delphi Forum -- by DelphiLand ]

Posted by Lionel on January 09, 2004 at 02:26:32:

Using the following Delphi code I get the results I want but I have not been able to get a fractional exponent such as 1/2 or 1/3 to work. If I use 0.5 or 0.33333 as an exponent in the [exp(Y*ln(X)] formular I get the square root and cube root with no problems but what if I wanted to use 1/8 as an exponent? would I have to use 0.1250 instead? The following code is what I am using but I have not had much luck trying to use a fraction in EditBox2. Is there a simple solution to this dilemma?

//================================
Var
X,
Y,
Result : Variant;
Begin
X:=Edit1.Text; //Input X
YL=Edit2.Text; //Input Y
//-------------------------
//
Result:=exp(Y*ln(X));

//----------------------------
// Show result
Edit3.Text:=(FloatToStrF(Result,ffFixed,8,8));
end;
//====================================


Related Articles and Replies:


[ Post Followup ] [ Delphi Forum ]
[ DelphiLand: free Delphi source code, tips, tutorials ]