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.

FractionalPart property

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: ~>0.1

property FractionalPart: TFraction;

Description

This property provides the fractional part of a TFraction when viewed as a mixed fraction. The fractional part is always a proper fraction, i.e. its absolute value is less than 1.

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.FractionalPart.Numerator = 1)      // 21/4 = 5 + 1/4
    and (F.FractionalPart.Denominator = 4));
  F := TFraction.Create(-21, 4);
  Assert((F.FractionalPart.Numerator = -1)     // -21/4 = -5 + -1/4
    and (F.FractionalPart.Denominator = 4));
  F := TFraction.Create(5, 11);
  Assert((F.FractionalPart.Numerator = 5)      // 5/11 = 0 + 5/11
    and (F.FractionalPart.Denominator = 11));
  F := TFraction.Create(60, 6);
  Assert((F.FractionalPart.Numerator = 0)      // 60/6 = 6 + 0/6
    and (F.FractionalPart.Denominator = 6));
  F := -7;
  Assert((F.FractionalPart.Numerator = 0)      // // -7/1 = -7 + 0/1
    and (F.FractionalPart.Denominator = 1));
end;

See Also