MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / bytes

Function bytes

src/dpp/utility.cpp:379–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379std::string bytes(uint64_t c) {
380 char print_buffer[64] = { 0 };
381 if (c > 1099511627776) { // 1TB
382 snprintf(print_buffer, 64, "%.2fT", (c / 1099511627776.0));
383 } else if (c > 1073741824) { // 1GB
384 snprintf(print_buffer, 64, "%.2fG", (c / 1073741824.0));
385 } else if (c > 1048576) { // 1MB
386 snprintf(print_buffer, 64, "%.2fM", (c / 1048576.0));
387 } else if (c > 1024) { // 1KB
388 snprintf(print_buffer, 64, "%.2fK", (c / 1024.0));
389 } else { // Bytes
390 return std::to_string(c);
391 }
392 return print_buffer;
393}
394
395uint32_t rgb(double red, double green, double blue) {
396 return (((uint32_t)(red * 255)) << 16) | (((uint32_t)(green * 255)) << 8) | ((uint32_t)(blue * 255));

Callers

nothing calls this directly

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected