convert percentage to decimals

I would like to change percentage to decimal in C#. The number of decimals may vary.  For example here are 3 numbers.
I would like to show them as
How is best to do that?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Can you clarify?

the commas look off.  Why would 84 = 8,4?  How would you change it back?

What about  larger numbers?

johnson1Author Commented:
If there is a zero at the end it will not show.
So 100.00 will be shown 100
In percentage max number of decimals are 2, i.e. 90.48.   90.481 is not possible.
The percentage will be from 0 to 100. I want to change it to the scale 0-10.
Kyle AbrahamsSenior .Net DeveloperCommented:
What about rounding?

what does 5 %  mean on a scale of 0 - 10?  (0 or 1)?

As a starter:
Decimal d = 98.923;
Int Scaler = Math.Round(d/10, 0);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anarki_jimbelSenior DeveloperCommented:
Personally, I'm a bit surprised with the choice to express percentage in the scale from 0 to 10. Usually it's 0-1 or 0 - 100.

Anyway, try the following code:

        private void button7_Click(object sender, EventArgs e)
            decimal[] nums ={91.5m,84m,90.48m};

            // convert to range 0 - 10 and remove trailing 0s allowing 3 digits after decimal point
            foreach (decimal n in nums)
                decimal x = n / 10;
                string numberToPrint = x.ToString("G4");

Open in new window

Output will be:


Open in new window

johnson1Author Commented:
Thank you. Sorry for late reply.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.