• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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
0
cdfllc
Asked:
cdfllc
  • 2
1 Solution
 
TertioptusCommented:
0
 
TertioptusCommented:
String.Format({"0:0.000}",numDbl);                                  
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now