What does exp=floor(log10(static_cast<double>(n))); mean?
I got the algorithm on internet but I dont get what this part means.
int spatiu (int n)
{
int exp = floor(log10(static_cast<double>(n)));
int div;
while (n != 0)
{
div = pow(10.0, exp);
cout << n / div << " ";
n %= div;
exp--;
}
cout << endl;
}
>Solution :
here
floor(log10(static_cast<double>(n)));
floor() function is used to take value in round off example 12.6 means floor value is 11.
static_cast<double>(n) is used here to "n" typecast in double. and log10() is used to take log10(n) of a number.
summary is floor(log10(static_cast<double>(n))); is used to calculate the length of number-1; for example n= 153, then function return 2 as a output.