I want to convert number to QString
with 3 significant digits.
QString::number(myNumber,'f',3);
does the job but remains trailing zeros. How to use it without them.
Also I've tried 'g'
and which shouldn't remain those zeros:
QString::number(myNumber,'g',3);
but for example 472.76 is converted to 473. That surprised me. Why is it so with 'g'
option?
However I am interested in 'f'
format. So the main question is how to do it with 'f'
without trailing zeros?
Input -> Desired output
472.76 -> 472.76
0.0766861 -> 0.077
180.00001 -> 180