anchor.diff:      Value := -Value;
   end;
   
  +const
  +  KDigitValues: array['0'..'z'] of Integer =
  +  (
  +  // 0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   @
  +     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1, -1,
  +  // A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   `
  +    10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
  +  // a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z
  +    10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
  +  );
  +
   // cf. Brent, Zimmermann, "Modern Computer Arithmetic", algorithm 1.23
  -class function BigInteger.TryParse(const S: string; Base: TNumberBase; out Value: BigInteger): Boolean;
  +//class function BigInteger.TryParse(const S: string; Base: TNumberBase; var Value: BigInteger): Boolean;
  +//var
  +//  LIsNegative: Boolean;
  +//  LTrimmed: string;
  +//  LVal: Integer;
  +//  P: PChar;
  +//  ValData: TMagnitude;
  +//  ValSize: Integer;
  +//  BigIntBase: BigInteger;
  +//  Res, Res2: BigInteger;
  +//begin
  +//  Result := False;
  +//  LTrimmed := Trim(S);
  +//  if LTrimmed = '' then
  +//    Exit;
  +//  LIsNegative := False;
  +//  BigIntBase := Base;
  +//
  +//  Res := BigInteger.Zero;
  +//  Res2 := BigInteger.Zero;
  +//  Value.FSize := 0;
  +//  Value.FData := nil;
  +////  Value.MakeSize(Length(S) div CStringMinLengths[Base] + 4);
  +//
  +//  P := PChar(LTrimmed);
  +//  if (P^ = '-') or (P^ = '+') then
  +//  begin
  +//    LIsNegative := (P^ = '-');
  +//    Inc(P);
  +//  end;
  +////  if Base = 10 then
  +////    Result := InternalParseDecimal(P, Value)
  +////  else if Base = 16 then
  +////    Result := InternalParseHex(P, Value)
  +////  else
  +//  begin
  +//    while P^ <> #0 do
  +//    begin
  +//      if (P^ = '_') or (P^ = ' ') or (P^ = ',') then
  +//      begin
  +//        Inc(P);
  +//        Continue;
  +//      end;
  +//      LVal := Ord(P^);
  +//      Inc(P);
  +//      if LVal in [Ord('0')..Ord('9')] then
  +//        Dec(LVal, CNumBase)
  +//      else if LVal >= CAlphaBase then
  +//      begin
  +//        if LVal >= Ord('a') then
  +//          Dec(LVal, 32);
  +//        Dec(LVal, CAlphaBase - 10);
  +//      end
  +//      else
  +//        Exit;
  +//      if LVal >= Base then
  +//        Exit;
  +//      //$$RV: debug
  +//      Res2 := Res * Base;
  +//      Res := Res2 + LVal;// + LVal;
  +//      Writeln(Res.ToString);
  +////      Value := Value * Base + LVal;
  +//      //$$RV: ~debug
  +////      InternalMultiplyAndAdd16(Value.FData, Base, LVal, Value.FData);
  +//    end;
  +//    Result := True;
  +//  end;
  +//  if not Result then
  +//  begin
  +//    Value := BigInteger.Zero;
  +//    Exit;
  +//  end;
  +////  Value := Res;
  +////  Value.Compact;
  +//  if LIsNegative then
  +//    Value := -Value;
  +//end;
  +
  +class function BigInteger.TryParse(const S: string; ABase: TNumberBase; var AValue: BigInteger): Boolean;
   var
  -  LIsNegative: Boolean;
  -  LTrimmed: string;
     LVal: Integer;
     P: PChar;
  -begin
  -  Result := False;
  +  LTrimmed: string;
  +  LNegative: Boolean;
  +begin
  +  LNegative := False;
  +  AValue := BigInteger.Zero;
     LTrimmed := Trim(S);
  -  if LTrimmed = '' then
  -    Exit;
  -  LIsNegative := False;
  -  Value.FSize := 0;
  -  Value.MakeSize(Length(S) div CStringMinLengths[Base] + 4);
     P := PChar(LTrimmed);
  -  if (P^ = '-') or (P^ = '+') then
  -  begin
  -    LIsNegative := (P^ = '-');
  +  if (P^ = '+') or (P^ = '-') then
  +  begin
  +    LNegative := P^ = '-';
       Inc(P);
     end;
  -  if Base = 10 then
  -    Result := InternalParseDecimal(P, Value)
  -  else if Base = 16 then
  -    Result := InternalParseHex(P, Value)
  -  else
  -  begin
  -    while P^ <> #0 do
  +  while P^ <> #0 do
  +  begin
  +    if (P^ = '_') or (P^ = ' ') or (P^ = ',') then
       begin
  -      if (P^ = '_') or (P^ = ' ') or (P^ = ',') then
  -      begin
  -        Inc(P);
  -        Continue;
  -      end;
  -      LVal := Ord(P^);
         Inc(P);
  -      if LVal in [Ord('0')..Ord('9')] then
  -        Dec(LVal, CNumBase)
  -      else if LVal >= CAlphaBase then
  -      begin
  -        if LVal >= Ord('a') then
  -          Dec(LVal, 32);
  -        Dec(LVal, CAlphaBase - 10);
  -      end
  -      else
  -        Exit;
  -      if LVal >= Base then
  -        Exit;
  -      InternalMultiplyAndAdd16(Value.FData, Base, LVal, Value.FData);
  +      Continue;
       end;
  -    Result := True;
  -  end;
  -  if LIsNegative then
  -    Value := -Value;
  -  Value.Compact;
  +    if (P^ >= '0') and (P^ <= 'z') then
  +    begin
  +      LVal := KDigitValues[P^];
  +      if (LVal = -1) or (LVal >= ABase) then
  +        Exit(False);
  +      AValue := AValue * ABase + BigInteger(LVal);
  +      // AValue := AValue * BigInteger(ABase) + BigInteger(LVal);
  +    end
  +    else
  +      Exit(False);
  +    Inc(P);
  +  end;
  +  if LNegative then
  +    AValue := -AValue;
  +  Result := True;
   end;
   
   const
  
positive.code:     else
      begin
        Data := Result.FData[LimbIndex];
        Result.FData[LimbIndex] := -(-Data and not BitMask);
        Inc(LimbIndex);
  
        // Propagate borrow
  
negative.code: {   2017-01-15: Reworked SetBit, ClearBit and FlipBit.                       }
  {                                                                            }
  {   2017-07-14: Changed all manual aligns to use .ALIGN 16                   }
  {                                                                            }
  {   2017-08-17: Removed buffer overflow bugs in InternalMultiplyAndAdd16 and }
  {               UncheckedDivModKnuth. Also removed bug from                  }
  {               InternalShiftLeft. All after using FastMM4 in full debug     }
  {               mode (which adds extra footer bytes to every allocation).    }
  {                                                                            }
  {----------------------------------------------------------------------------}
  {   Also see GitHub commit comments.                                         }
  {----------------------------------------------------------------------------}
  
  unit Velthuis.BigIntegers;
  
  {///////////////////////////////////////////////////////////////////////////////////////////////
  
     FastMM4 complains about buffer overruns (corrupted block footers)
     =================================================================
  
     - Got rid of the one in TryParse, caused by InternalMultiplyAndAdd16.
     - Got rid of the one in UncheckedDivModKnuth.
     - Must update InternalMultiplyAndAdd32 too (code almost the same as InternalMultiplyAndAdd16).
     - Must revert TryParse(... Base, ...) to old version and check that too.
  
   ///////////////////////////////////////////////////////////////////////////////////////////////}
  
  { TODO:
    - Remove local BigIntegers where possible. Removing Res from class function BigInteger.Add sped
  