Convert double to string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry for the stupid question but,

how can I convert a double to string by setting the number of decimal digits ?

Thank you in advance.

Keven Corazza
 
use Math.Round() to get the desired number of significant digits and then
just ToSring() the result.

-Darren Shaffer
 
You need to use double.ToString("Fn") where n is the number of decimal
digits you need:
double d = 27.5673;
Debug.Write(d.ToString("F2"));
produces
27.57

Notice the rounding being done.
 
Back
Top