+ 1
How to format float data type while inputting and outputting and what exactly does "%x.yf" mean ?
I have seen the float being formatted as 5.2f, 3.2f etc. What exactly do these mean? How the storing/printing is affected by this? Edit: How are "%5.2" and "%3.2f" different? When to use which?
3 Answers
0
In outputting a float, x means the minimum number of characters that will be printed. The y is the precision, it is the number of digits to be printed after decimal point.
It's slighty different in input format
You can refer to http://www.cplusplus.com/reference/cstdio/scanf for input format and http://www.cplusplus.com/reference/cstdio/printf for the output
+ 3
There isn't like meaning or something. It's just that f helps it to be distinct from a double.
- 2
What?