Remove traling zeros from QString scientific notation num value

I have the next code, this code print a value in scientific notation, but i want to remove the trailing zeros

valor = 541; QString cStyleResult = QString::number(valor.toDouble(), 'e');

qDebug() << cStyleResult ;

//////////////////////////////////////////////

output: 5.410000e2

I want to remove the trailing zeros(right decimal zeros), example I want to save only the value of 5.41

some ideas????

Re: Remove traling zeros from QString scientific notation num value

Hi, you could

- specifiy a precision as the third parameter for QString::number

- you could use QString::arg() and play with fieldwidth and precision

- you could take your string, find the e or E of the scientific notation, and remove all zeroes in front of it (probably the ugliest method...)

- probably many more...

Ginsengelf