+ 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?

3rd Jul 2019, 3:54 PM
Ritobrata Ghosh
Ritobrata Ghosh - avatar
3 Respostas
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
3rd Jul 2019, 4:41 PM
Agent_I
Agent_I - avatar
+ 3
There isn't like meaning or something. It's just that f helps it to be distinct from a double.
3rd Jul 2019, 4:11 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
- 2
What?
4th Jul 2019, 7:16 AM
Read