static void Main()
{
var result1 = Converter.ConvertToInt32("922336666");
//result1 one return as 922336666
var result2 = Converter.ConvertToInt64("92233720368547758");
//result2 one return as 92233720368547760
}
}
public static class Converter {
public static int ConvertToInt32(string input) {
return Convert.ToInt32(Math.Round(Convert.ToDouble(input)));
}
public static Int64 ConvertToInt64(string input)
{
return Convert.ToInt64(Math.Round(Convert.ToDouble(input)));
}
}
I am getting result2 rounded up to 92233720368547760 but result1 is kept the same. Can some one explain. When using ToDouble does round up the int ?