mardi 28 juin 2016

How to get the number of digit in double value in c++?

I have tried to get the number of digit from double value but it is not working properly. Can you please help me to get the exact number of digit in double.

I have tried as :

int main()
{
    double value = 123456.05;
    std::cout<<"number of digit::"<<((int)std::log10(value ) + 1);
}

output::

number of digit::6

But the number of digit is 9. How to get exact number of digit. In my case 9.

Aucun commentaire:

Enregistrer un commentaire