conveting string to decimal

Feb 21, 2015 at 11:45pm
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
Feb 22, 2015 at 5:13am
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
Topic archived. No new replies allowed.