8 #include <QtAlgorithms> 16 return __builtin_clzll(v);
21 int power, base = 1000;
29 QLocale locale = QLocale::system();
32 const QString number = power
33 ? locale.toString(bytes / std::pow(
double(base), power),
'f', qMin(precision, 3 * power))
34 : locale.toString(bytes);
38 Q_ASSERT(power <= 6 && power >= 0);
43 case 1: unit =
"KiB";
break;
44 case 2: unit =
"MiB";
break;
45 case 3: unit =
"GiB";
break;
46 case 4: unit =
"TiB";
break;
47 case 5: unit =
"PiB";
break;
48 case 6: unit =
"EiB";
break;
54 return number + QLatin1Char(
' ') + unit;
QString formattedDataSize(qint64 bytes, int precision)
static uint countLeadingZeroBits(quint64 v)