Arash - 1 year ago 92

C# Question

How can I get a count of the total number of digits of a number in C#? For example, the number 887979789 has 9 digits.

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Without converting to a string you could try:

```
Math.Ceiling(Math.Log10(n));
```

**Correction following ysap's comment:**

```
Math.Floor(Math.Log10(n) + 1);
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**