diff --git a/templates/lib/util.cpp b/templates/lib/util.cpp index 2e9cb956..b3fbd0eb 100644 --- a/templates/lib/util.cpp +++ b/templates/lib/util.cpp @@ -26,6 +26,8 @@ #include #include +#include + QString Cutelee::unescapeStringLiteral(const QString &input) { return input.mid(1, input.size() - 2) @@ -263,15 +265,19 @@ std::pair Cutelee::calcFileSize(qreal size, int unitSystem, qreal QStringLiteral("YB") }); - bool found = false; int count = 0; const qreal baseVal = (_unitSystem == 10) ? 1000.0f : 1024.0f; +#if FLT_EVAL_METHOD == 2 + // Avoid that this is treated as long double, as the increased + // precision breaks the comparison below. + volatile qreal current = 1.0F; +#else qreal current = 1.0f; +#endif int units = decimalUnits.size(); - while (!found && (count < units)) { + while (count < units) { current *= baseVal; if (_size < current) { - found = true; break; } count++;