SystemSqrt (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

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

Code

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;

Uses