MCPcopy Create free account
hub / github.com/Cpasjuste/pplay / formatSize

Method formatSize

src/utility.cpp:136–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136std::string Utility::formatSize(size_t size) {
137
138 static const char *sizes[] = {"B", "KB", "MB", "GB"};
139 int div = 0;
140 size_t rem = 0;
141
142 while (size >= 1024 && (size_t) div < (sizeof sizes / sizeof *sizes)) {
143 rem = (size_t) (size % 1024);
144 div++;
145 size /= 1024;
146 }
147
148 double size_d = (float) size + (float) rem / 1024.0;
149 return convertToString(roundOff(size_d)) + " " + sizes[div];
150}
151
152void Utility::setCpuClock(const CpuClock &clock) {
153#ifdef __SWITCH__

Callers

nothing calls this directly

Calls 2

convertToStringFunction · 0.85
roundOffFunction · 0.85

Tested by

no test coverage detected