Skip to content

"strtod range over" for self generated json #186

Description

@takei-yuya
int main()
{
   std::ostringstream oss;
   double d = 6.92837873186e-310;
   
   // https://github.com/retrieva/pficommon/blob/master/src/text/json/base.h#L263
   oss << std::setprecision(12) << d;
   std::cout << oss.str() << std::endl;
   
   // https://github.com/retrieva/pficommon/blob/master/src/text/json/parser.cpp#L284
   std::string s = oss.str();
   char* endptr;
   double d2 = strtod(s.c_str(), &endptr);
   std::cout << "d2 = "  << d2 << ", errno = " << errno << "(" << std::strerror(errno) << ")" << std::endl;
}
6.92837873186e-310
d2 = 6.92838e-310, errno = 34(Numerical result out of range)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions