cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
rounding decimal numbers
rounding decimal numbers
Oct 29, 2015 at 7:41pm UTC
Tores1
(6)
Hi forum i need help with rounding of numbers i have some array of numbers type float and i need fix it
for example
1
2
float
f1=5.558;
float
f2=5.1;
to f1=5.558,f2=5.100
values from array are different and i need all edit to 3 decimal places
ty and sorry for my english
Oct 29, 2015 at 7:43pm UTC
jlb
(4973)
You may want to look into using some of the functions from the <iomanip> header file since it looks like a display issue.
Oct 29, 2015 at 8:04pm UTC
Tores1
(6)
Yes I tried function from <iomanip> concretely
cout<<setprecision(3)<<f1;
But its not result for me
Oct 29, 2015 at 8:12pm UTC
jlb
(4973)
You'll probably also want to use "fixed" and possibly "showpoint"
http://www.cplusplus.com/reference/ios/showpoint/
If that doesn't help you'll need to show the code that illustrating what you're trying to do and ask specific questions based on that code.
Topic archived. No new replies allowed.