MCPcopy Create free account
hub / github.com/apache/arrow / GetNumDigits

Function GetNumDigits

cpp/src/arrow/acero/tpch_node.cc:530–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

528};
529
530int GetNumDigits(int64_t x) {
531 // This if statement chain is for MAXIMUM SPEED
532 // Source:
533 // https://stackoverflow.com/questions/1068849/how-do-i-determine-the-number-of-digits-of-an-integer-in-c
534 ARROW_DCHECK(x >= 0);
535 if (x < 10ll) return 1;
536 if (x < 100ll) return 2;
537 if (x < 1000ll) return 3;
538 if (x < 10000ll) return 4;
539 if (x < 100000ll) return 5;
540 if (x < 1000000ll) return 6;
541 if (x < 10000000ll) return 7;
542 if (x < 100000000ll) return 8;
543 if (x < 1000000000ll) return 9;
544 if (x < 10000000000ll) return 10;
545 if (x < 100000000000ll) return 11;
546 if (x < 1000000000000ll) return 12;
547 if (x < 10000000000000ll) return 13;
548 if (x < 100000000000000ll) return 14;
549 if (x < 1000000000000000ll) return 15;
550 if (x < 10000000000000000ll) return 16;
551 if (x < 100000000000000000ll) return 17;
552 if (x < 1000000000000000000ll) return 18;
553 Unreachable("Positive 64-bit integer should never have more than 18 digits");
554 return -1;
555}
556
557void AppendNumberPaddedToNineDigits(char* out, int64_t x) {
558 size_t kPad = 9;

Callers 2

C_NAMEMethod · 0.85

Calls 1

UnreachableFunction · 0.85

Tested by

no test coverage detected