我有代码,设置的小区的默认值到单元格的值以上乘以100:为什么10亿* 100 == 12亿?
const int DUCKBILL_MULTIPLIER = 100;
. . .
cellValue = dataGridViewPlatypi.Rows[args.RowIndex - 1].Cells[0].Value;
if (Convert.ToInt32(cellValue) > 0)
{
int nextDefaultVal = Convert.ToInt32(cellValue) * DUCKBILL_MULTIPLIER;
cellValue = nextDefaultVal;
}
prevVal = cellValue == null ? string.Empty : cellValue.ToString();
. . .
dataGridViewPlatypi.Rows[args.RowIndex].Cells[args.ColumnIndex].Value = prevVal;
但是,一旦上述值上是十亿(1十亿)时,下一个值是1215752192 (1,215,752,192或约12亿美元)而不是1,000亿美元。我知道最大整数值是2,147,483,647(约21亿);我知道最大整数值是2,147,483,647(约21亿);我知道最大整数值是2,147,483,647(约21亿)。那么为什么下一个值是1,215,752,192而不是2,147,483,647?
顺便说一句,这些vals大于应用程序将需要,但我发现这在测试“极端”的情况下。
整数溢出...整数不饱和。他们翻身。 – Mysticial