Hello
I am facing a strange behaviour of QString::number that I can not explain even after reading the documentation over and over again.
qDebug
() <<
QString::number( 62.5,
'g' );
qDebug
() <<
QString::number( 62.5,
'g',
1 );
qDebug
() <<
QString::number( 62.5,
'g',
2 );
qDebug
() <<
QString::number( 62.5,
'g',
4 );
qDebug
() <<
QString::number( 62.5,
'g',
5 );
qDebug
() <<
QString::number( 62.5,
'g',
6 );
qDebug() << QString::number( 62.5, 'g' );
qDebug() << QString::number( 62.5, 'g', 1 );
qDebug() << QString::number( 62.5, 'g', 2 );
qDebug() << QString::number( 62.5, 'g', 4 );
qDebug() << QString::number( 62.5, 'g', 5 );
qDebug() << QString::number( 62.5, 'g', 6 );
To copy to clipboard, switch view to plain text mode
Produces this output:
"62.5"
"6e+01"
"62"
"62.5"
"62.5"
"62.5"
"62.5"
"6e+01"
"62"
"62.5"
"62.5"
"62.5"
To copy to clipboard, switch view to plain text mode
Now I dont understand why the "62" without the .5 result of the result line from "qDebug() << QString::number( 62.5, 'g', 2 ); "
Any explaination on what I am doing wrong? The format options 'e' and 'f' are not interessting for me right now.
Greetings
sas
Bookmarks