Mega Code Archive

 
Categories / Delphi / Examples
 

How do i create a power function

Question: How do I create a power function? Answer: The following example shows how to use the example power function to raise three to the power of 2: function Power(x, y : extended) : extended; begin result := exp(y*ln(x)); end; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(FloatToStr(Power(3, 2))); end;