Answers for "length of int c++"

C++
1

c++ int length

ex: input = 2424, output = 4
static int intlen(int n)
{
  if (n == 0) return 1;
  else if (n < 0) return 2 + static_cast<std::size_t>(std::log10(-n));
  else if (n > 0) return 1 + static_cast<std::size_t>(std::log10(n));
}
Posted by: Guest on October-16-2021
-1

c++ length of int

unsigned int number_of_digits = 0;

do {
     ++number_of_digits; 
     n /= base;
} while (n);
Posted by: Guest on September-10-2020
-1

length of int c++

sizeof(num);
Posted by: Guest on October-12-2020

Browse Popular Code Answers by Language