Added some improvements for TBigInt shift left operator
This commit is contained in:
parent
4329041353
commit
2df8266d42
10
UBigInt.pas
10
UBigInt.pas
|
@ -626,8 +626,11 @@ var
|
|||
begin
|
||||
// Handles shift of zero.
|
||||
if A = 0 then
|
||||
Result := TBigInt.Zero
|
||||
else begin
|
||||
begin
|
||||
Result := TBigInt.Zero;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Determines full digit shifts and bit shifts.
|
||||
DivMod(B, CBitsPerDigit, digitShifts, bitShifts);
|
||||
|
||||
|
@ -654,7 +657,7 @@ begin
|
|||
Result.FDigits[i] := Result.FDigits[i] or (A.FDigits[j] << bitShifts);
|
||||
end;
|
||||
|
||||
if Length(Result.FDigits) > newLength then
|
||||
if lastDigit > 0 then
|
||||
Result.FDigits[newLength] := lastDigit;
|
||||
end
|
||||
else begin
|
||||
|
@ -669,7 +672,6 @@ begin
|
|||
|
||||
Result.FIsNegative := A.IsNegative;
|
||||
end;
|
||||
end;
|
||||
|
||||
operator shr(const A: TBigInt; const B: Integer): TBigInt;
|
||||
var
|
||||
|
|
|
@ -732,7 +732,8 @@ end;
|
|||
|
||||
{ TBigIntShiftLeftTestCase }
|
||||
|
||||
procedure TBigIntShiftLeftTestCase.Test(const AHexValueOperand: string; const AShift: Integer; const AHexValueResult: string);
|
||||
procedure TBigIntShiftLeftTestCase.Test(const AHexValueOperand: string; const AShift: Integer; const AHexValueResult:
|
||||
string);
|
||||
var
|
||||
a, s: TBigInt;
|
||||
begin
|
||||
|
|
Loading…
Reference in New Issue