Tuesday, July 14, 2009

What does cout.setf (ios::fixed | iso:: showpoint); and cout.precision(4) means in a c++ code?

What does cout.setf (ios::fixed | iso:: showpoint); and cout.precision(4) means in a c++ code.

What does cout.setf (ios::fixed | iso:: showpoint); and cout.precision(4) means in a c++ code?
those are flags for your output. cout.setf is a function to set the flags


ios::fixed - Display floating point values using normal notation (as opposed to scientific)





ios::showpoint - Display a decimal and extra zeros, even when not needed.





cout.setprecision(4) is limiting the precision of your number to 4 decimal places. so if you had a double d = 3.14159 and you did a cout.setprecision(4) you would get 3.142
Reply:chinga tu madre
Reply:i have no idea. I learned a lil bit of C++ 1 and half year ago. right now, I can remember nothing but "#include"
Reply:hello!


setf means that you will set the flag. fixed means that to display real values in a fixed notation and showpoint is to display a trailing decimal point and trailing decimal zeros when real numbers are displayed. and last precision means you set the output into 4 decimal places.





hope that would help. God bless! =)

sundew

No comments:

Post a Comment