Skip to content

Incorrect dumping of parsed numbers with exponents, but without decimal places #230

@nlohmann

Description

@nlohmann

The new floating point representation (#201) has a bug when it comes to negative exponents. Number 2342e-2 is correctly duped as 23.42, but when it is parsed from a string, the output is 2e01.

Example code:

json j2a = 2342e-2;
json j2b = json::parse("2342e-2");

CHECK(j2a.dump() == "23.42");
CHECK(j2b.dump() == "2342e-2");

Output:

FAILED:
  CHECK( j2b.dump() == "2342e-2" )
with expansion:
  "2e01" == "2342e-2"

@twelsby Any idea about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions