MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / IntToDigitCount

Function IntToDigitCount

native/thirdpart/flatbuffers/util.h:90–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88
89#ifdef FLATBUFFERS_PREFER_PRINTF
90template<typename T> size_t IntToDigitCount(T t) {
91 size_t digit_count = 0;
92 // Count the sign for negative numbers
93 if (t < 0) digit_count++;
94 // Count a single 0 left of the dot for fractional numbers
95 if (-1 < t && t < 1) digit_count++;
96 // Count digits until fractional part
97 T eps = std::numeric_limits<float>::epsilon();
98 while (t <= (-1 + eps) || (1 - eps) <= t) {
99 t /= 10;
100 digit_count++;
101 }
102 return digit_count;
103}
104
105template<typename T> size_t NumToStringWidth(T t, int precision = 0) {
106 size_t string_width = IntToDigitCount(t);

Callers 1

NumToStringWidthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected