diff --git a/UBigInt.pas b/UBigInt.pas index a49ea16..4c8505e 100644 --- a/UBigInt.pas +++ b/UBigInt.pas @@ -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;