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.
Project: Fractions
Unit: DelphiDabbler.Lib.Fractions
Record: TFraction
Applies to: ~>0.1
function Convert(const Multiplier: Int64): TFraction;
This method returns a new fraction whose numerator and denominator are integer multiples of the current fraction. The original and new fractions are equivalent.
The Multiplier parameter specifies the multiplier to be applied. Multiplier must be greater than zero.
var
F, FConv: TFraction;
begin
F := TFraction.Create(1, 2);
FConv := F.Convert(6); 1/2 * 6/6 = 6/12
Assert((FConv.Numerator = 6) and (FC.Denominator = 12));
Assert(F = FConv); // equivalent
F := TFraction.Create(-5, 13); -5/13 * 3 = -15/39
FConv := F.Convert(3);
Assert((FConv.Numerator = -15) and (FC.Denominator = 39));
Assert(F = FConv);
F := 0;
FConv := F.Convert(7); 0/1 * 7/7 = 0/7
Assert((FConv.Numerator = 0) and (FC.Denominator = 7));
Assert(F = FConv);
F := 3; 3/1 * -3/-3 = -9/-3 = 9/3
FConv := F.Convert(-3);
Assert((FConv.Numerator = 9) and (FC.Denominator = 3));
Assert(F = FConv);
end;