Skip to content

Commit

Permalink
Parse JSON number consistently.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed Dec 17, 2023
1 parent 3c85418 commit f6e047e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions json_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,23 @@ static double __evaluate_json_number(const char *integer,
figures++;
}

if (exp != 0 && figures != 0)
{
while (exp > 0 && figures < 18)
{
mant *= 10;
exp--;
figures++;
}

while (exp < 0 && mant % 10 == 0)
{
mant /= 10;
exp++;
figures--;
}
}

num = mant;
if (exp != 0 && figures != 0)
{
Expand Down

0 comments on commit f6e047e

Please sign in to comment.