Project: Fractions
Unit: DelphiDabbler.Lib.Fractions
Record: TFraction
Applies to: ~>0.1
class function Max(const A, B: TFraction): TFraction; overload; static;
class function Max(const FA: array of TFraction): TFraction; overload; static;
These overloaded methods find and return the largest of a series of fractions.
The first overload returns the largest of the two given fractions, A and B.
The second method returns the largest fraction in the given array of fractions, FA. This array must have at least one element.
This example uses the array overload of Max along with the associated Min 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;