Fixed BigInt subtraction for equal operands
This commit is contained in:
parent
62887ad1d7
commit
18de900a38
11
UBigInt.pas
11
UBigInt.pas
|
@ -237,10 +237,17 @@ class function TBigInt.SubtractAbsoluteValues(constref AA, AB: TBigInt; const AR
|
||||||
var
|
var
|
||||||
a, b: TBigInt;
|
a, b: TBigInt;
|
||||||
carry: Cardinal;
|
carry: Cardinal;
|
||||||
i, j, lastNonZeroDigitIndex, len: Integer;
|
compare, i, j, lastNonZeroDigitIndex, len: Integer;
|
||||||
begin
|
begin
|
||||||
// Establishes the operand order, such that Abs(a) is not less than Abs(b).
|
// 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
|
begin
|
||||||
a := AA;
|
a := AA;
|
||||||
b := AB;
|
b := AB;
|
||||||
|
|
Loading…
Reference in New Issue