473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Converting double to string

Hi,

I am using the following command to convert a double to string:

string.ToString("#.00")

So 8.888 becomes 8.89.
But 0.8888 becomes .89

How do i process the string so it retains the leading 0 to become
'0.89'

Thanks
Arun

Sep 18 '06 #1
3 1722
Hi Arun,

Will this work ?

double num = 0.80;
Console.WriteLine(num.ToString("N"));

Regards,
C.C.Chakkaradeep

"ar*********@gmail.com" wrote:
Hi,

I am using the following command to convert a double to string:

string.ToString("#.00")

So 8.888 becomes 8.89.
But 0.8888 becomes .89

How do i process the string so it retains the leading 0 to become
'0.89'

Thanks
Arun

Sep 18 '06 #2

<ar*********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hi,

I am using the following command to convert a double to string:

string.ToString("#.00")

So 8.888 becomes 8.89.
But 0.8888 becomes .89

How do i process the string so it retains the leading 0 to become
'0.89'

Thanks
Arun
double d = 0.88d;
string s = d.ToString("0.00");

works for me :)

HTH,
Mythran
Sep 18 '06 #3
You should use the formatting string as "0.00" instead of "#.00"

Have a look at this:

http://msdn.microsoft.com/library/de...ricformats.asp

--
Nand Kishore Gupta
"ar*********@gmail.com" wrote:
Hi,

I am using the following command to convert a double to string:

string.ToString("#.00")

So 8.888 becomes 8.89.
But 0.8888 becomes .89

How do i process the string so it retains the leading 0 to become
'0.89'

Thanks
Arun

Sep 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: matt melton | last post by:
Hi there, I am trying to write a method that accepts an array of any primitive type and will return the same array without copying memory as an array of bytes. ie. I'd like to be able to do...
4
by: Cyde Weys | last post by:
I'm currently working on converting a simulator program from Visual Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but there's still one thing I haven't gotten to and I've never...
4
by: rainmaker1234 | last post by:
Its very simple in VC++. In the followeing code I have declared a String, and a double than I am taking the string and converting it into Double. getch() at the end is only to pause the screen so...
5
by: shang | last post by:
Hi! I am trying to find a function that converts a string into a double or a long double number. I found atod() but I don't know which library I have to include to use it. Could someone help me? ...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
5
by: SMichal | last post by:
Hi, how can I parse string "? 20.000" to double ?
10
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox...
3
by: nvx | last post by:
Hi, I'm looking for a simple way to convert a Double to a String exactly the .ToString() does, except these two differences: - the number of decimals is given (rounding is applied if necessary),...
25
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have...
7
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795 (Radians) There's a valid reason to use single...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.