while_e
27th September 2017, 17:45
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);
This result will be:
0.05
0.05
0.0500
0.0500
false
I have worked around these issues in the past with silly stuff like:
var1 = (double)((int)((var1*100)+0.5))/100;
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?
// 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);
This result will be:
0.05
0.05
0.0500
0.0500
false
I have worked around these issues in the past with silly stuff like:
var1 = (double)((int)((var1*100)+0.5))/100;
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?