Updated operators
This commit is contained in:
parent
5a3c320942
commit
cec6985489
13
UBigInt.pas
13
UBigInt.pas
|
@ -74,11 +74,12 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
operator := (const A: Int64): TBigInt;
|
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, 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 shl (const A: TBigInt; const B: Integer): TBigInt;
|
||||||
operator = (const A: TBigInt; const B: Int64): Boolean;
|
operator = (const A, B: TBigInt): Boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -418,12 +419,12 @@ begin
|
||||||
Result := TBigInt.AddAbsoluteValues(A, B, A.IsNegative);
|
Result := TBigInt.AddAbsoluteValues(A, B, A.IsNegative);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
operator * (const A: TBigInt; const B: Int64): TBigInt;
|
operator * (const A, B: TBigInt): TBigInt;
|
||||||
begin
|
begin
|
||||||
if (A = 0) or (B = 0) then
|
if (A = TBigInt.Zero) or (B = TBigInt.Zero) then
|
||||||
Result := TBigInt.Zero
|
Result := TBigInt.Zero
|
||||||
else
|
else
|
||||||
Result := TBigInt.MultiplyAbsoluteValues(A, B, A.IsNegative = (B > 0));
|
Result := TBigInt.MultiplyAbsoluteValues(A, B, A.IsNegative <> B.IsNegative);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
operator shl(const A: TBigInt; const B: Integer): TBigInt;
|
operator shl(const A: TBigInt; const B: Integer): TBigInt;
|
||||||
|
@ -475,7 +476,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
operator = (const A: TBigInt; const B: Int64): Boolean;
|
operator = (const A, B: TBigInt): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := A.CompareTo(B) = 0;
|
Result := A.CompareTo(B) = 0;
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue