16 const char kBigSIUnits[] =
"kMGTPEZY";
18 const char kBigIECUnits[] =
"KMGTPEZY";
20 const char kSmallSIUnits[] =
"munpfazy";
24 "SI and IEC unit arrays must be the same size");
26 "Small SI and Big SI unit arrays must be the same size");
35 std::stringstream mantissa_stream;
38 mantissa_stream <<
"-";
44 const double adjusted_threshold =
46 const double big_threshold = adjusted_threshold * one_k;
47 const double small_threshold = adjusted_threshold;
49 const double simple_threshold = 0.01;
51 if (val > big_threshold) {
54 for (
size_t i = 0;
i <
arraysize(kBigSIUnits); ++
i) {
56 if (scaled <= big_threshold) {
57 mantissa_stream << scaled;
63 mantissa_stream << val;
65 }
else if (val < small_threshold) {
67 if (val < simple_threshold) {
69 for (
size_t i = 0;
i <
arraysize(kSmallSIUnits); ++
i) {
71 if (scaled >= small_threshold) {
72 mantissa_stream << scaled;
79 mantissa_stream << val;
82 mantissa_stream << val;
92 if (
index >= kUnitsSize)
return "";
95 (
exponent > 0 ? (iec ? kBigIECUnits : kBigSIUnits) : kSmallSIUnits);
112 std::stringstream ss;
128 va_copy(args_cp,
args);
132 std::array<char, 256> local_buff;
133 std::size_t
size = local_buff.size();
142 if (
static_cast<std::size_t
>(
ret) <
size)
147 size =
static_cast<std::size_t
>(
ret) + 1;
148 auto buff_ptr = std::unique_ptr<char[]>(
new char[
size]);
165 std::size_t
start = 0;