I have a division like this:
number / 1000.0
Sometimes it gives answers like 96.0000000001, sometimes the division works as expected.
I want to limit my number to a maximum of two decimal places and without trailing zeros.
If it's 96.5500000001 it should show 96.55.
If it's 96.4000000001 it should show 96.4
It is possible to format a string in this way?
I've checked the documentation and it provides 'f' argument for specifying the number of the decimal places but this way the trailing zeros remain. This is what I have tried:
QString::number(number / 1000.0, 'f', 2)
But this gives me for 96.4000000001 --> 96.40 instead of 96.4
Any solution? How can I format in this way?