SystemAbs (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example converts negative floating-point numbers and integers to positive ones.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := '-2.3';
  Edit3.Text := FloatToStr(Abs(StrToFloat(Edit1.Text)));	{ 2.3 }
  Edit2.Text := '-157';
  Edit4.Text := IntToStr(Abs(StrToInt(Edit2.Text)));	{ 157 }
end;

Uses

Personal tools
Assistance