redis_client icon indicating copy to clipboard operation
redis_client copied to clipboard

double ConvertToString error

Open iptcp opened this issue 8 years ago • 1 comments

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 $

iptcp avatar Nov 30 '16 17:11 iptcp

#include >

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

Hope this is helpful.

shawn246 avatar Dec 07 '16 09:12 shawn246