double.Parse produces overflow exception on double.MinValue

S

Samuel R. Neff

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)
at System.Double.Parse(String s, NumberStyles style,
IFormatProvider provider)
at System.Double.Parse(String s)


double.MinValue is obviously a valid double so double.Parse should be
able to parse it's string represntation. So is this a bug? Is there
a work-around?


the actual code is this:


if(data is long || data is ulong || data is float || data is double ||
data is decimal)
{
WriteDouble(double.Parse(data.ToString()));
return;
}

Which could be improved, but double.Parse should still work in this
scenario.

Thanks,

Sam
 

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

Top