Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"strtod range over" for self generated json #186

Open
takei-yuya opened this issue Jan 23, 2018 · 0 comments
Open

"strtod range over" for self generated json #186

takei-yuya opened this issue Jan 23, 2018 · 0 comments

Comments

@takei-yuya
Copy link
Member

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant