In the Method below on the last line I’m always getting an exception:
System.OverflowException: Value was either too large or too small for an Int32.
I can’t really explain why because I’m checking explicitly for that:
private Int32 ConvertValue(double value)
{
if (value > Int32.MaxValue)
{
Console.WriteLine("Couldn't convert value " + value + " to Int32");
return Int32.MaxValue;
}
else if (value < Int32.MinValue)
{
Console.WriteLine("Couldn't convert value " + value + " to Int32");
return Int32.MinValue;
}
else
{
return Convert.ToInt32(value);
}
}
Also check
double.IsNaN(value).Compares with
NaNalways yield false.