Project: Fractions
Unit: DelphiDabbler.Lib.Fractions
Record: TFraction
Applies to: ~>0.1
function IsProper: Boolean;
The IsProper method checks if a TFraction instance is a proper fraction and returns True if so or False if not.
A proper fraction is one whose absolute value is less than 1, i.e. the absolute value of its numerator is less than its denominator.
var
F: TFraction;
begin
F := TFraction.Create(-2, 3);
Assert(F.IsProper);
F := TFraction.Create(3, 4);
Assert(F.IsProper);
F := TFraction.Create(7, 4);
Assert(not F.IsProper);
end;
Another test for a proper fraction is to check whether its WholeNumberPart property is 0. If the property is 0 then the fraction is proper, otherwise it is not.