Force 3 decimals

Hi, I am wondering, is there a way to force a number to come back with at least 3 decimal places.

if I use:

string returnValue      = "";
double numDbl            = 0;
string numText            = "";
if( numericFieldText != null && !numericFieldText.Equals("") )
{
      numDbl      = System.Convert.ToDouble(numericFieldText);
      numDbl      = System.Math.Round(numDbl,3);
      numText = numDbl.ToString();                                          
}


System.Math.Round(numDbl,3);
returns just a number like 7.76, for example.

I would like it to return 7.760

thanks,
ccfllc
LVL 1
cdfllcAsked:
Who is Participating?
 
TertioptusCommented:
String.Format({"0:0.000}",numDbl);                                  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.