-
Notifications
You must be signed in to change notification settings - Fork 299
Open
Description
Hi
I changed the code of ParseElement a bit so it has some checks on long values near their min/max (see https://wvdvegt.wordpress.com/2018/04/26/double-precision-issues/ for details on the issue):
private static JSONNode ParseElement(string token, bool quoted)
{
...
double val;
if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
return val;
else
return token;
}
into
private static JSONNode ParseElement(string token, bool quoted)
{
...
//! Patched start.
Boolean isLong = (longAsString && long.TryParse(token, out long lval));
if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out double rval))
{
if (isLong && !rval.ToString("F0").Equals(token))
return token;
else
return rval;
}
else
return token;
//! Patched end.
}
Fix can probably optimized a bit by mainly using the rval.ToString("F0").Equals(token) check
Metadata
Metadata
Assignees
Labels
No labels