0

I have a variable of double data type.It has only 1 decimal point or no decimal point such as 17.5 and 17.I want to have exact two decimal point for it.Does anyone know?

2
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by johnsonlim026
0
public void TestDoubleFormat()
      {
         string format = "0.00";

         double d = 12; 
         string s = d.ToString(format);
         d = 12.1; 
         s += ", " + d.ToString(format);
         d = 12.12;
         s += ", " + d.ToString(format);

         lblOutput.Text = s;
      }

Output:

12.00, 12.10, 12.12

I have a variable of bouble data type.It has only 1 decimal point or no decimal point such as 17.5 and 17.I want to have exact two decimal point for it.Does anyone know?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.