I would like to create a function that can set the decimal length based on the length of the whole number.

Lets say I have these numbers:

```
100.12345
10.123456
1.1234567

```

The total length of the whole number should be 5, and the decimal separator should be adjusted so it fits 5 numbers. This is my desired output:

```
100.12
10.123
1.1234

```

Is there any easy way to accomplish this in C#?

UPDATE: To be more clear in my question on how the conversion should be.

(Current number > Formatted number)

```
100000.222 > 100000
10.222222  > 10.222
1.22       > 1.22
1          > 1
0.2222     > 0.2222

```