cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
conveting string to decimal
conveting string to decimal
Feb 21, 2015 at 11:45pm UTC
insaneassassin
(4)
In my project i have to take the string valve and convert it into float
for example
100 will be 100.00
100.0012 will be invalid
100.00 will stay as it is
99 will be 99.00
i m thinking of using stof but i m stuck on how to set the precision of 2
Feb 22, 2015 at 12:21am UTC
programmercarlito
(50)
Here is the set precision syntax
http://www.cplusplus.com/reference/iomanip/setprecision/
Feb 22, 2015 at 5:13am UTC
sly858
(27)
you will also need to use a fixed declaration before it
cout << fixed << setpreciosion(2) << x
Last edited on
Feb 22, 2015 at 5:39am UTC
Topic archived. No new replies allowed.