RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Sqrt Function

Returns the square root of X.

Pascal
function Sqrt(const X: Extended): Extended;
C++
Extended Sqrt(const Extended X);

X is a Delphi floating-point expression. The result is the square root of X.  

Delphi Examples: 

 

{
This example uses the System Sqr and Sqrt functions to calculate
the some mathematical values.
}

procedure TForm1.Button1Click(Sender: TObject);
var
  S, Temp: string;
begin
   Str(Sqr(5.5):3:1, Temp);
   S := '5.5 squared is ' + Temp + #13#10;
   MessageDlg(S, mtInformation, [mbOk], 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  S, Temp: string;
begin
   Str(Sqrt(2.0):5:4, Temp);
   S := S + 'The square root of 2 is ' + Temp;
   MessageDlg(S, mtInformation, [mbOk], 0);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!