quint64 a = 11;
double b = 0.1;
double v = a / b;
quint64 v1 = a / b;
quint64 v2 = v;
quint64 v3 = (double)((double)a / (double)b);
qDebug() << QObject::tr("v = %1, v1 = %2, v2 = %3, v3 = %4").arg(v).arg(v1).arg(v2).arg(v3);
I tried the code in Qt creator as pasted, which use mingw compiler. The result is as following:
"v = 110, v1 = 109, v2 = 110, v3 = 109"
My question is, why v1 and v3 are both 109? How the compiler deal with such a sentence 'a / b'? And how can I get result v3 as 110 in one line?