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

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -