sastrian
7th September 2012, 08:27
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 );
Produces this output:
"62.5"
"6e+01"
"62"
"62.5"
"62.5"
"62.5"
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
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 );
Produces this output:
"62.5"
"6e+01"
"62"
"62.5"
"62.5"
"62.5"
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