timmay3141
Programmer
I want to know how to show the correct amount of precision with printf. For example, if I say printf("%f", fVal) and fVal is 1, it shows 1.00000, and I want it to show 1 or 1.0. If fVal is 1.23, I want it to show 1.23, not 1.23000 or 1.2. In other words, I want to show the amount of precision that the value passed actually has, which means I can't just send "%f" or "%.2f" to printf. Is there a way to do what I'm trying to do?