c++ - Converting from string to float creates unnecessary decimals -


p->gettext(buf2,32); float area = atof(buf2); 

when 9.2 in buf2, gets automatically converted 9.245.

can tell me why happen, (i have restricted float value upto 3 decimal places)?

have you've tried setting precision higher? std::setprecision(4) << buf2

also try doing 0 fill on base on character count of string possibly?


Comments

Popular posts from this blog

mysql - java.sql.SQLException Parameter index out of range (1 > number of parameters, which is 0) -

c - ALSA programming: how to stop immediately -