How can one dump the exact value of a double variable to the console/terminal? I can do something like this:
// var1 & var2 are both set elsewhere
qDebug() << var1;
qDebug() << var2;
qDebug
() <<
QString::number(var1,
'f',
4);
qDebug
() <<
QString::number(var2,
'f',
4);
qDebug() << (var1 == var2);
// var1 & var2 are both set elsewhere
qDebug() << var1;
qDebug() << var2;
qDebug() << QString::number(var1,'f',4);
qDebug() << QString::number(var2,'f',4);
qDebug() << (var1 == var2);
To copy to clipboard, switch view to plain text mode
This result will be:
0.05
0.05
0.0500
0.0500
false
0.05
0.05
0.0500
0.0500
false
To copy to clipboard, switch view to plain text mode
I have worked around these issues in the past with silly stuff like:
var1 = (double)((int)((var1*100)+0.5))/100;
var1 = (double)((int)((var1*100)+0.5))/100;
To copy to clipboard, switch view to plain text mode
I'm not asking for the best workaround for rounding these numbers, merely what is the easiest way to dump the exact value of the variable, and not have it formatted via QT in some way?
Bookmarks