Project: Fractions
Unit: DelphiDabbler.Lib.Fractions
Record: TFraction
Applies to: ~>0.1
class operator Round(const F: TFraction): Int64;
The operator overload enables the Round “operator” or compiler function to operate on a TFraction. The operator rounds the fraction to the nearest whole number value.
var
F: TFraction;
begin
F := TFraction.Create(17, 3);
Assert(Round(F) = 6);
F := TFraction.Create(-17, 3);
Assert(Round(F) = -6);
F := TFraction.Create(-58, 7);
Assert(Round(F) = -8);
F := TFraction.Create(3, 1);
Assert(Round(F) = 3);
F := TFraction.Create(-3, 1);
Assert(Round(F) = -3);
F := TFraction.Create(0, 1);
Assert(Round(F) = 0);
end;