Added TBigInt unequal operator
This commit is contained in:
parent
5808ec24f2
commit
71c8462358
11
UBigInt.pas
11
UBigInt.pas
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue