Ad
Numbers
Data Types
Integers
Algorithms
Logic

A much more sane route

Code
Diff
  • #include <stdint.h>
    
    uint_fast8_t number_of_digits(uint64_t n)
    {
      uint_fast8_t digits = 0;
      for (; n > 0; n /= 10) digits++;
      return digits;
    }
    • #include <stdint.h>
    • uint_fast8_t number_of_digits(uint64_t n)
    • {
    • return printf("%lu", n);
    • uint_fast8_t digits = 0;
    • for (; n > 0; n /= 10) digits++;
    • return digits;
    • }