c# - Why doesn't it throw OverFlow Exception? -
c# - Why doesn't it throw OverFlow Exception? -
this question has reply here:
no overflow exception int in c#? 6 answers why checked calculation not throw overflowexception? 3 answerssample 1
int = int32.minvalue; int b = -a; console.writeline("a={0}",a); console.writeline("b={0}", b);
result
a=-2147483648 b=-2147483648
sample 2
int = int32.minvalue; int b = a-1; console.writeline("a={0}",a); console.writeline("b={0}", b);
result
a=-2147483648 b=2147483647
in 2 samples: why doesn't throw overflow exception. when tried these samples in java environment, got same results. there can explain situation?
c# .net
Comments
Post a Comment