这是个很奇怪的问题 一个double的大于0的数字转int后 竟然变成了负数
后来F12进入Int32里面看了发现 原来这个数字超过了Int32的最大值了
Int32的范围:
// 摘要: // 表示 System.Int32 的最大可能值。此字段为常数。 public const int MaxValue = 2147483647; // // 摘要: // 表示 System.Int32 的最小可能值。此字段为常数。 public const int MinValue = -2147483648;
Int16的范围:
// 摘要: // 表示 System.Int16 的最大可能值。此字段为常数。 public const short MaxValue = 32767; // // 摘要: // 表示 System.Int16 的最小可能值。此字段为常数。 public const short MinValue = -32768;
Int64的范围:
// 摘要: // 表示 Int64 的最大可能值。此字段为常数。 public const long MaxValue = 9223372036854775807; // // 摘要: // 表示 Int64 的最小可能值。此字段为常数。 public const long MinValue = -9223372036854775808;
所以这里只能用Int64进行转换了。。。