Min class methods

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: ~>0.1

class function Min(const A, B: TFraction): TFraction; overload; static;
class function Min(const FA: array of TFraction): TFraction; overload; static;

Description

These overloaded methods find and return the smallest of a series of fractions.

The first overload returns the smallest of the two given fractions, A and B.

The second method returns the smallest fraction in the given array of fractions, FA. This array must have at least one element.

Example

This example uses the array overload of Min along with the associated Max method to find the smallest range that contains all fractions in a given array.

type
  TFractionRange = record
    Lo, Hi: TFraction;
  end;

function FindRange(const A: array of TFraction): TFRactionRange;
begin
  Result.Lo := TFraction.Min(A);
  Result.Hi := TFraction.Max(A);
end;

See Also