MCPcopy Create free account
hub / github.com/BirolLab/abyss / bytesToSI

Function bytesToSI

Common/StringUtil.h:50–63  ·  view source on GitHub ↗

Return the SI representation of a number in bytes. */

Source from the content-addressed store, hash-verified

48
49/** Return the SI representation of a number in bytes. */
50static inline std::string bytesToSI(size_t n)
51{
52 std::ostringstream s;
53 s << std::setprecision(3);
54 if (n < 1024)
55 s << n;
56 else if (n < (1ULL<<20))
57 s << (double)n/(1ULL<<10) << "k";
58 else if (n < (1ULL<<30))
59 s << (double)n/(1ULL<<20) << "M";
60 else
61 s << (double)n/(1ULL<<30) << "G";
62 return s.str();
63}
64
65/**
66 * Convert a quantity with SI units to the equivalent floating

Callers 2

buildFiltersFunction · 0.85
TESTFunction · 0.85

Calls 1

strMethod · 0.45

Tested by 1

TESTFunction · 0.68