# Convert.ToDouble最大、最小值转换问题？ • ### Question

• double dbl1 = Convert.ToDouble(double.MinValue.ToString());
double dbl2 = Convert.ToDouble(double.MaxValue.ToString());
未处理 System.OverflowException
Message="对于 Double 类型，值或者太大，或者太小。"
Source="mscorlib"

Friday, November 18, 2011 8:04 AM

• boss

The actual min value is -1.7976931348623157E+308 but while converting this to string, this value will be rounded of to some higher value as "-1.79769313486232E+308".

so u r getting the exception avoid rounding off... by using the following code

string min = double.MinValue.ToString("R");
double operand1 = Convert.ToDouble(min);

• Proposed as answer by Friday, November 18, 2011 8:21 AM
• Marked as answer by Monday, November 21, 2011 5:12 AM
Friday, November 18, 2011 8:17 AM

### All replies

• double dbl = (double)Convert.ChangeType(double.MinValue.ToString(), Type.GetType("System.Double"));
也是同样错误！按照http://msdn.microsoft.com/zh-cn/library/zh1hkw6k.aspx的说明
只当value 小于 Double.MinValue 或大于 Double.MaxValue 的数字才会报OverflowException 的。为什么这里也报错呢？

Friday, November 18, 2011 8:10 AM
• boss

The actual min value is -1.7976931348623157E+308 but while converting this to string, this value will be rounded of to some higher value as "-1.79769313486232E+308".

so u r getting the exception avoid rounding off... by using the following code

string min = double.MinValue.ToString("R");
double operand1 = Convert.ToDouble(min);

• Proposed as answer by Friday, November 18, 2011 8:21 AM
• Marked as answer by Monday, November 21, 2011 5:12 AM
Friday, November 18, 2011 8:17 AM
• Thanks!
Monday, November 21, 2011 5:16 AM