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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top