Added TBigInt unequal operator

This commit is contained in:
Stefan Müller 2024-03-14 11:44:28 +01:00 committed by Stefan Müller
parent 9f619adc01
commit cdd989042b
1 changed files with 11 additions and 0 deletions

View File

@ -73,6 +73,8 @@ type
class function FromInt64(const AValue: Int64): TBigInt; static;
end;
{ Operators }
operator := (const A: Int64): TBigInt;
operator - (const A: TBigInt): TBigInt;
operator + (const A, B: TBigInt): TBigInt;
@ -80,6 +82,7 @@ type
operator * (const A, B: TBigInt): TBigInt;
operator shl (const A: TBigInt; const B: Integer): TBigInt;
operator = (const A, B: TBigInt): Boolean;
operator <> (const A, B: TBigInt): Boolean;
implementation
@ -388,6 +391,8 @@ begin
end;
end;
{ Operators }
operator := (const A: Int64): TBigInt;
begin
Result := TBigInt.FromInt64(A);
@ -427,6 +432,7 @@ begin
Result := TBigInt.MultiplyAbsoluteValues(A, B, A.IsNegative <> B.IsNegative);
end;
// TODO: Shift operator could be implemented with a single Move call, but I do not want to change it without test cases.
operator shl(const A: TBigInt; const B: Integer): TBigInt;
var
i, j, digitShifts, bitShifts, reverseShift, len, newLength: Integer;
@ -481,5 +487,10 @@ begin
Result := A.CompareTo(B) = 0;
end;
operator <> (const A, B: TBigInt): Boolean;
begin
Result := A.CompareTo(B) <> 0;
end;
end.