Consider the following code:
long longMaxValue = long.MaxValue;
decimal decimalMaxValue = decimal.MaxValue;
int a = (int)longMaxValue;
int b = (int)decimalMaxValue;
Question # 1: Why casting longMaxValueup intleads to -1?
Question # 2: Why casting decimalMaxValuein intleads to the following exception. BUT listing longMaxValue- intnot?
The value was too large or too small for Int32.
source
share