這是個很奇怪的問題 一個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進行轉換了。。。