SystemTrunc (Delphi)
From RAD Studio XE2 Code Examples
Language:
Description
This example demonstrates how the Trunc function operates on various real numbers.
Code
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;
Uses
- System.Trunc ( fr | de | ja )