Skip to content

Commit f6e047e

Browse files
committed
Parse JSON number consistently.
1 parent 3c85418 commit f6e047e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

json_parser.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ static double __evaluate_json_number(const char *integer,
345345
figures++;
346346
}
347347

348+
if (exp != 0 && figures != 0)
349+
{
350+
while (exp > 0 && figures < 18)
351+
{
352+
mant *= 10;
353+
exp--;
354+
figures++;
355+
}
356+
357+
while (exp < 0 && mant % 10 == 0)
358+
{
359+
mant /= 10;
360+
exp++;
361+
figures--;
362+
}
363+
}
364+
348365
num = mant;
349366
if (exp != 0 && figures != 0)
350367
{

0 commit comments

Comments
 (0)