| 904 | } // namespace |
| 905 | |
| 906 | std::string FormatMeasure(double n, const char* unit) |
| 907 | { |
| 908 | // see http://zh.wikipedia.org/wiki/%E5%9B%BD%E9%99%85%E5%8D%95%E4%BD%8D%E5%88%B6%E8%AF%8D%E5%A4%B4 |
| 909 | static const char* const base_prefixes[] = { |
| 910 | "y", "z", "a", "f", "p", "n", "u", "m", // negative exponential |
| 911 | "", "k", "M", "G", "T", "P", "E", "Z", "Y" |
| 912 | }; |
| 913 | static const int negative_prefixes_size = 8; |
| 914 | static const int prefixes_size = TOFT_ARRAY_SIZE(base_prefixes); |
| 915 | |
| 916 | const char* const* prefixes = base_prefixes + negative_prefixes_size; |
| 917 | |
| 918 | return NumberToHumanReadableString<double, 1000>( |
| 919 | n, prefixes, unit, -negative_prefixes_size, |
| 920 | prefixes_size - negative_prefixes_size - 1); |
| 921 | } |
| 922 | |
| 923 | std::string FormatBinaryMeasure(int64_t n, const char* unit) |
| 924 | { |