How to get the number of digits in an int with C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int n = 8532719;
     
        int digits = (int)(Math.Log10(n) + 1);
        
        Console.WriteLine(digits);
    }
}



/*
run:

7

*/

 



answered Jun 5, 2020 by avibootz

Related questions

1 answer 106 views
1 answer 175 views
1 answer 87 views
1 answer 151 views
2 answers 163 views
2 answers 162 views
4 answers 317 views
...