473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert double.MinValue to string and back


Why does this not work, and how should i do this convert in stead:

string x = double.MinValue .ToString();
double y = Convert.ToDoubl e(x);

i get this exception:
An unhandled exception of type 'System.Overflo wException' occurred in mscorlib.dll
Additional information: Value was either too large or too small for a Double.

Pascal
Nov 15 '05 #1
2 4962
Hello Pascal,

Because
string x = double.MinValue .ToString();
rounds x to -1.7976931348623 2E+308, whereas the actual minimum value
is -1.7976931348623 157E+308. This is a bit higher, so you get the overflow
error when you try to convert it back.

Try using
string x = double.MinValue .ToString("R");
to convert using the 'round trip' (no rounding) format instead.

I hope that helps.
"Pascal" <pa****@unknown .com> wrote in message
news:c1******** **@reader08.wxs .nl...

Why does this not work, and how should i do this convert in stead:

string x = double.MinValue .ToString();
double y = Convert.ToDoubl e(x);

i get this exception:
An unhandled exception of type 'System.Overflo wException' occurred in mscorlib.dll Additional information: Value was either too large or too small for a Double.
Pascal

Nov 15 '05 #2
yes it helped, thanks!

"Pascal" <pa****@unknown .com> wrote in message
news:c1******** **@reader08.wxs .nl...

Why does this not work, and how should i do this convert in stead:

string x = double.MinValue .ToString();
double y = Convert.ToDoubl e(x);

i get this exception:
An unhandled exception of type 'System.Overflo wException' occurred in mscorlib.dll Additional information: Value was either too large or too small for a Double.
Pascal

Nov 15 '05 #3

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

Similar topics

2
5869
by: Juan | last post by:
Best way to convert back a currency string into a number(int or long)? If I have, for example, $ 15.000,00 what is the best way to make it again an int or long? pls help!, Juan.
3
7773
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a DB and display it onscreen. No matter which way I open the file, convert it to Unicode/leave it as is or what ever, I see all single bytes ok, but double bytes become 2 seperate single bytes. Surely there is an easy way to convert these mixed...
5
709
by: msnews.microsoft.com | last post by:
How can I convert string to int?
2
27319
by: Laurence | last post by:
I want to convert a double value to string. 1.2345678911 -> "1.234567891" 123 -> "123" I used the following code to convert it: string str = doubleValue.ToString("f9"); but the second value is converted to "123.000000000".
1
5415
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a web form to upload a TIFF image (scanned images) and convert it to a JPEG before I insert it into SQL Server. The file upload part works great, but I can;t convert the image. I certainly don't want to upload it the the server filesystem, convert...
17
4376
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge problem writing VB Double values to the file so as the Pascal program can read them as Pascal Real values. I've managed to find the algorithm to read the Pascal Real format and convert it to a VB Double, but I cannot figure out the opposite...
2
3502
by: Samuel R. Neff | last post by:
I'm using a quasi open-source project and am running into an exception in double.Parse which is effectively this: double.Parse(double.MinValue.ToString()) System.OverflowException: Value was either too large or too small for a Double. at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info)
3
8748
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; this produced an error
9
12103
by: =?Utf-8?B?Qnlyb24=?= | last post by:
How do you convert a hex string into a double using C# in framework v2.0? I've seen this question answered before, but apparently something has changed in 2.0 that negates the old solution that I've seen. The code: DoubleVariable = Double.Parse(HexString, NumberStyles.AllowHexSpecifier); results in the error: "The number style AllowHexSpecifier is not supported on floating point data
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.