I need to convert a float number into 2 decimal format.I have tried Math.round(AmountSpent1,2)
This is my code:
float AmountSpent1 = float.Parse(FixedAmount);
Math.Round(AmountSpent1, 2);
I need to convert a float number into 2 decimal format.I have tried Math.round(AmountSpent1,2)
This is my code:
float AmountSpent1 = float.Parse(FixedAmount);
Math.Round(AmountSpent1, 2);
float AmountSpent1 = float.Parse(FixedAmount);
decimal m =Convert.ToDecimal(AmountSpent1);
decimal d = Math.Round(m, 2);
You could simply try this one
DecimalFormat df=new DecimalFormat("#.##");
For Example
float AmountSpent1 = float.Parse(FixedAmount);
System.out.println(df.format(AmountSpent1));