Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions templates/lib/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <QtCore/QStringList>
#include <QDebug>

#include <cfloat>

QString Cutelee::unescapeStringLiteral(const QString &input)
{
return input.mid(1, input.size() - 2)
Expand Down Expand Up @@ -263,15 +265,19 @@ std::pair<qreal,QString> 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++;
Expand Down