MCPcopy Create free account
hub / github.com/apache/impala / DoubleToString

Method DoubleToString

be/src/gutil/strings/human_readable.cc:99–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99string HumanReadableNumBytes::DoubleToString(double num_bytes) {
100 const char *neg_str = GetNegStr(&num_bytes);
101 static const char units[] = "BKMGTPEZY";
102 double scaled = num_bytes;
103 int i = 0;
104 for (; i < arraysize(units) && scaled >= 1024.0; ++i) {
105 scaled /= 1024.0;
106 }
107 if (i == arraysize(units)) {
108 return StringPrintf("%s%g", neg_str, num_bytes);
109 } else {
110 return StringPrintf("%s%.2f%c", neg_str, scaled, units[i]);
111 }
112}
113
114string HumanReadableNumBytes::ToString(int64 num_bytes) {
115 if (num_bytes == kint64min) {

Callers

nothing calls this directly

Calls 3

GetNegStrFunction · 0.85
StringPrintfFunction · 0.85
StringAppendFFunction · 0.85

Tested by

no test coverage detected