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

double ConvertToString error #7

Open
iptcp opened this issue Nov 30, 2016 · 1 comment
Open

double ConvertToString error #7

iptcp opened this issue Nov 30, 2016 · 1 comment

Comments

@iptcp
Copy link

iptcp commented Nov 30, 2016

1480525631---1.48053e+09

std::string ConvertToString(double t)
{
std::stringstream sstream;
sstream << t;
return sstream.str();
}

int main(int argc, char *argv[])
{
time_t t = time(NULL);
double dt = (long) t;
std::cout<<std::to_string((int)t)<<"---"<<dt<<std::endl;
std::cout<<ConvertToString(dt)<<"---"<<std::endl;
return 0;
}
/opt/work/debug $ ./hh
1480525631---1.48053e+09
1.48053e+09---
/opt/work/debug $

@shawn246
Copy link
Owner

shawn246 commented Dec 7, 2016

#include >

std::string ConvertToString(double t)
{
std::stringstream sstream;
sstream << std::fixed << t;
return sstream.str();
}

Hope this is helpful.

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

2 participants