Updated operators

This commit is contained in:
Stefan Müller 2024-02-14 11:59:42 +01:00 committed by Stefan Müller
parent 5a3c320942
commit cec6985489
1 changed files with 7 additions and 6 deletions

View File

@ -74,11 +74,12 @@ type
end;
operator := (const A: Int64): TBigInt;
operator - (const A: TBigInt): TBigInt;
operator + (const A, B: TBigInt): TBigInt;
operator - (const A, B: TBigInt): TBigInt;
operator * (const A: TBigInt; const B: Int64): TBigInt;
operator * (const A, B: TBigInt): TBigInt;
operator shl (const A: TBigInt; const B: Integer): TBigInt;
operator = (const A: TBigInt; const B: Int64): Boolean;
operator = (const A, B: TBigInt): Boolean;
implementation
@ -418,12 +419,12 @@ begin
Result := TBigInt.AddAbsoluteValues(A, B, A.IsNegative);
end;
operator * (const A: TBigInt; const B: Int64): TBigInt;
operator * (const A, B: TBigInt): TBigInt;
begin
if (A = 0) or (B = 0) then
if (A = TBigInt.Zero) or (B = TBigInt.Zero) then
Result := TBigInt.Zero
else
Result := TBigInt.MultiplyAbsoluteValues(A, B, A.IsNegative = (B > 0));
Result := TBigInt.MultiplyAbsoluteValues(A, B, A.IsNegative <> B.IsNegative);
end;
operator shl(const A: TBigInt; const B: Integer): TBigInt;
@ -475,7 +476,7 @@ begin
end;
end;
operator = (const A: TBigInt; const B: Int64): Boolean;
operator = (const A, B: TBigInt): Boolean;
begin
Result := A.CompareTo(B) = 0;
end;