Fixed BigInt subtraction for equal operands

This commit is contained in:
Stefan Müller 2024-05-20 00:56:22 +02:00
parent 62887ad1d7
commit 18de900a38
1 changed files with 9 additions and 2 deletions

View File

@ -237,10 +237,17 @@ class function TBigInt.SubtractAbsoluteValues(constref AA, AB: TBigInt; const AR
var
a, b: TBigInt;
carry: Cardinal;
i, j, lastNonZeroDigitIndex, len: Integer;
compare, i, j, lastNonZeroDigitIndex, len: Integer;
begin
// Establishes the operand order, such that Abs(a) is not less than Abs(b).
if (AA.CompareToAbsoluteValues(AB) >= 0) then
compare := AA.CompareToAbsoluteValues(AB);
if compare = 0 then
begin
Result := Zero;
Exit;
end;
if compare > 0 then
begin
a := AA;
b := AB;