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.

Reciprocal method

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: ~>0.1

function Reciprocal: TFraction;


This method returns the reciprocal of the fraction. The fraction must not be zero, i.e. it must have a non-zero numerator.

The reciprocal of fraction X/Y is Y/X, where X<>0.


Because the reciprocal of any non-zero number N is defined as 1/N, applying Reciprocal to a fraction is the same as dividing the fraction into 1. I.e. if F is any TFraction instance with a non-zero numerator,

F.Reciprocal = 1/F;


  F, G, H: TFraction;
  F := TFraction.Create(5, 12);
  G := F.Reciprocal;
  H := 1 / F;  // see Note
  Assert(G = H);
  Assert((G.Numerator = F.Denominator) and (G.Denominator = F.Numerator));

See Also