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

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

Description

Returns the absolute value of the given fraction F.

The returned fraction is not simplified.

Example

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;

See Also