reducing a percentage value to desired decimal places

I have a gui label which is to display a percentage value. how can i reduce it to 1 or 2 decimal places?

GUI.Label(new Rect(50, 100, 50, 50), System.Convert.ToString(Calculate(ten)) + "%");
float Calculate(int card)
{
    float total= (float)card/(float)deck*100;
    return total;
}

Check this question.

Any reason for using System.Convert.ToString() instead of Calculate(ten).ToString()?

Using System;
Using System.Collections;

decimal Calculate( int card )
{
    float total = (float)card/(float)deck*100;
    decimal totalDecimal = (decimal)Math.Round( total, 2 );
    return totalDecimal;
}

I think that should work, it’s off the top of my head and may not compile, if so let me know and I’ll try to fix it. In order to use decimal casting and regular Math.Round, you have to include the System namespace at the top.

GUI.Label(new Rect(50, 100, 50, 50), System.String.Format(“{0:.00}”, Calculate(ten)) + “%”);