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 answers

sample 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

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -