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.

WholeNumberPart property

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: ~>0.1

property WholeNumberPart: Int64;

Description

This property provides the whole number part of a TFraction when considered as a mixed fraction.

For any TFraction it’s WholeNumberPart plus its FractionalPart is equal to the original fraction. I.e. for TFraction F

F = F.WholeNumberPart + F.FractionalPart;

Example

var
  F: TFraction;
begin
  F := TFraction.Create(21, 4);
  Assert(F.WholeNumberPart = 5);  // 21/4 = 5 + 1/4
  F := TFraction.Create(-21, 4);
  Assert(F.WholeNumberPart = -5); // -21/4 = -5 - 1/4
  F := TFraction.Create(5, 11);
  Assert(F.WholeNumberPart = 0);  // 5/11 = 0 + 5/11
  F := TFraction.Create(60, 6);
  Assert(F.WholeNumberPart = 10); // 60/6 = 6 + 0/6
  F := -7;
  Assert(F.WholeNumberPart = -7); // -7/1 = -7 + 0/1
end;

See Also