Not necessarily the most efficient, but one of the shortest and most readable using C++:
std::to_string(num).length()
More Related Contents:
- Efficient way to determine number of digits in an integer
- Are the character digits [‘0’..’9′] required to have contiguous numeric values?
- Write a c++ function that will prompt a user for an integer and convert it to binary and print in reverse order [duplicate]
- C++ convert hex string to signed integer
- What happens if I assign a negative value to an unsigned variable?
- Alternative to itoa() for converting integer to string C++? [duplicate]
- How to concatenate a std::string and an int
- C++ performance challenge: integer to std::string conversion
- Why does subtracting ‘0’ in C result in the number that the char is representing?
- What is special about numbers starting with zero?
- What does it mean when a numeric constant in C/C++ is prefixed with a 0?
- C++ handling very large integers
- How to elegantly check if a number is within a range?
- Addition of two chars produces int
- How to check if the input is a valid integer without any other chars?
- Definition of int64_t
- OpenMP set_num_threads() is not working
- How can I add and subtract 128 bit integers in C or C++ if my compiler does not support them?
- How to handle arbitrarily large integers
- How does a 32 bit processor support 64 bit integers?
- Loop until integer input is in required range fails to work with non-digit character inputs
- how to convert from int to char*?
- What is the best way to generate random numbers in C++?
- is it ok to specialize std::numeric_limits for user-defined number-like classes?
- What range of values can integer types store in C++?
- C++ floating point to integer type conversions
- c++ integer->std::string conversion. Simple function?
- What do the C and C++ standards say about bit-level integer representation and manipulation?
- convert string to integer in c++
- How to convert int to string in C++