| 97 | } |
| 98 | |
| 99 | string 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 | |
| 114 | string HumanReadableNumBytes::ToString(int64 num_bytes) { |
| 115 | if (num_bytes == kint64min) { |
nothing calls this directly
no test coverage detected