PC Review


Reply
Thread Tools Rate Thread

Convert double to string

 
 
=?Utf-8?B?S2V2ZW4gQ29yYXp6YQ==?=
Guest
Posts: n/a
 
      3rd Dec 2004
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

 
Reply With Quote
 
 
 
 
Darren Shaffer
Guest
Posts: n/a
 
      3rd Dec 2004
use Math.Round() to get the desired number of significant digits and then
just ToSring() the result.

-Darren Shaffer

"Keven Corazza" <(E-Mail Removed)> wrote in message
news:1A74F71B-3FAD-4E95-954E-(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      3rd Dec 2004
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.

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Keven Corazza" <(E-Mail Removed)> wrote in message
news:1A74F71B-3FAD-4E95-954E-(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert from String to Double Peter Newman Microsoft VB .NET 2 17th Apr 2009 04:46 PM
convert double to string Denis Microsoft C# .NET 2 28th Apr 2008 10:26 AM
double string convert Nicolai.Schoenberg@googlemail.com Microsoft C# .NET 2 6th Jul 2007 10:05 AM
Convert from double to string Marty Microsoft Dot NET 6 3rd Sep 2004 01:42 PM
how to convert string to double? cindy liu Microsoft Dot NET 4 7th Oct 2003 09:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:35 PM.