Updated operators
This commit is contained in:
parent
5a3c320942
commit
cec6985489
13
UBigInt.pas
13
UBigInt.pas
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue