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.

Abs class method

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: 0.1.x

class function Abs(const F: TFraction): TFraction; static;

Applies to: ~>0.2

class function Abs(const F: TFraction): TFraction; overload; static;
function Abs: TFraction; overload;

Description

Returns the absolute value of a fraction. The returned fraction is not simplified.

The class method operates on the fraction passed as parameter F.

[~>0.2] The instance method operates upon the fraction instance on which it is called.

Examples

Using the class method:

var
  F, G: TFraction;
begin
  F := TFraction.Create(3, 4);
  G := TFraction.Abs(F);
  Assert(G = +F);
  F := TFraction.Create(-7, 8);
  G := TFraction.Abs(F);
  Assert(G = -F);
end;

[~>0.2] Using the instance method:

var
  F, G: TFraction;
begin
  F := TFraction.Create(3, 4);
  G := F.Abs;
  Assert(G = +F);
  F := TFraction.Create(-7, 8);
  G := F.Abs;
  Assert(G = -F);
end;

See Also