Skip to content

A rare error when parsing huge integers #17

Description

@axiopost

Hi,
I am writing a faster parser function than the original one and while testing it I raised up an error that may be reproduce with this code:

procedure AParsingError;
var
  N,M : BigInteger;
  R : IRandom;
begin
  R := TDelphiRandom.Create(-332888001);
  N := BigInteger.Create(Random(100)*1000, R);
  BigInteger.Base := 12;
  M := BigInteger.Parse(N.ToString);
  if (N<>M) then raise Exception.Create('Parsed value differs from the original!');
end;

The N.ToString and M.ToString differs per the digits from positions 1983 to 1992 (probabely a Limb).
In attached file uBadValue.zip
there is a unit file embeding the value produced by the random generator (18250 hex-digits long), just in case.

Best regards,
F. MARQUES

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions