Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

Trunc operator overload

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: ~>0.1

class operator Trunc(const F: TFraction): Int64;


The operator overload enables the Trunc “operator” or compiler function to operate on a TFraction. The operator truncates the fraction to the nearest whole number in the direction of zero.


  F: TFraction;
  F := TFraction.Create(17, 3);
  Assert(Trunc(F) = 5);
  F := TFraction.Create(-58, 7);
  Assert(Trunc(F) = -8);
  F := TFraction.Create(3, 1);
  Assert(Trunc(F) = 3);
  F := TFraction.Create(-3, 1);
  Assert(Trunc(F) = -3);
  F := TFraction.Create(0, 1);
  Assert(Trunc(F) = 0);

See Also