MCPcopy Create free account
hub / github.com/F-Stack/f-stack / digits10

Function digits10

app/redis-6.2.6/src/util.c:276–294  ·  view source on GitHub ↗

Return the number of digits of 'v' when converted to string in radix 10. * See ll2string() for more information. */

Source from the content-addressed store, hash-verified

274/* Return the number of digits of 'v' when converted to string in radix 10.
275 * See ll2string() for more information. */
276uint32_t digits10(uint64_t v) {
277 if (v < 10) return 1;
278 if (v < 100) return 2;
279 if (v < 1000) return 3;
280 if (v < 1000000000000UL) {
281 if (v < 100000000UL) {
282 if (v < 1000000) {
283 if (v < 10000) return 4;
284 return 5 + (v >= 100000);
285 }
286 return 7 + (v >= 10000000UL);
287 }
288 if (v < 10000000000UL) {
289 return 9 + (v >= 1000000000UL);
290 }
291 return 11 + (v >= 100000000000UL);
292 }
293 return 12 + digits10(v / 1000000000000UL);
294}
295
296/* Like digits10() but for signed values. */
297uint32_t sdigits10(int64_t v) {

Callers 2

sdigits10Function · 0.85
ll2stringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected