unit SystemTrunc;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: SystemTrunc
// Routine: System.Trunc

// BeginCode
{
This example demonstrates how the Trunc function operates
on various real numbers.
}
procedure TForm1.Button1Click(Sender: TObject);
var
   S, T: string;
begin
   Str(1.4:2:1, T);
   S := T + ' Truncs to ' + IntToStr(Trunc(1.4)) + #13#10;
   Str(1.5:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(1.5)) + #13#10;
   Str(1.6:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(1.6)) + #13#10;
   Str(-1.4:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.4)) + #13#10;
   Str(-1.5:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.5)) + #13#10;
   Str(-1.6:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.6)) + #13#10;
   Str(2.5:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(2.5)) + #13#10;
   Str(-2.5:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(-2.5)) + #13#10;
   Str(-2.6:2:1, T);
   S := S + T + ' Truncs to ' + IntToStr(Trunc(-2.6));
   MessageDlg(S, mtInformation, [mbOk], 0, mbOk);
end;
// EndCode
// EndExample: SystemTrunc
end.
