I want to print floats points in a simple calculator program for iOS:
if the result of calculation is 5.555123125, then print the exact 5.555123125.
if the result is 1.2, then 1.2.
if 2.555, then 2.555. Not 2.56 or not 2.555000.
No zero paddings, no throwing away, no round-up-or-down’s. Just as it is.
Tried formatting with %f but I had to specify the number of digits: like %10.4f.
Tried %g but it did automatic changes according to the number of digits.
Just as it is, it is that difficult?
seems to work.