Linked Questions

23 votes
2 answers
5k views

Possible Duplicate: Why don’t languages raise errors on integer overflow by default? Why doesn't C# use arithmetic overflow checking by default? I figure that it would generally be better to have ...
Sam's user avatar
  • 42.8k
3 votes
2 answers
831 views

I used ILSpy to reflect into the LINQ's Sum method and noticed that it just does a foreach with the checked keyword. But if an int has a defined maximum and you try to go over it, why doesn't it ...
Xaisoft's user avatar
  • 46.9k
1 vote
0 answers
55 views

I had a theory that casting from long to int with a value greater than int.MaxValue or less than int.MinValue would result in an exception. The issue I had at the time was identifying which type of ...
Taco's user avatar
  • 2,953
278 votes
12 answers
223k views

How does Java handle integer underflows and overflows? Leading on from that, how would you check/test that this is occurring?
KushalP's user avatar
  • 11.2k
9 votes
3 answers
3k views

I can even calculate (expt 32768 32768) and I got: ...
Don Lun's user avatar
  • 2,777
8 votes
6 answers
2k views

This question stems from a bug where I iterated over a collection of Int64 and accidentally did foreach (int i in myCollection). I was trying to debug the baffling problem of how when I did a linq ...
NibblyPig's user avatar
  • 53.3k
12 votes
6 answers
6k views

Consider the example: >>> from sys import maxint >>> type(maxint) <type 'int'> >>> print maxint 9223372036854775807 >>> type(maxint+2) <type 'long'> >...
dawg's user avatar
  • 105k
10 votes
4 answers
2k views

During Java Arithmetic operation , JVM do not throw Underflow or Overflow Exception. So many time we come across unexpected results and wondering what went wrong. While in case of .NET technology we ...
Alpesh Gediya's user avatar
5 votes
2 answers
2k views

Seems that arithmetic overflow checking is turned off by default in c# due to performance reasons (see https://stackoverflow.com/a/108776/2406234 etc.). But if I do turn it on, either using the /...
shayac's user avatar
  • 594
8 votes
2 answers
1k views

I have learnt(atleast in java) that integer/long values overflow silently and their values start over from minimum value on overflow rather than throwing any exception. I was using an external api ...
Aqeel Ashiq's user avatar
  • 2,215
0 votes
1 answer
2k views

I accidentally discovered this today. Is this supposed to happen? Is this something we should all be warned about? Since this is an unsigned integer, shouldn't I have gotten an error? uint foo = 10; ...
Scott Jore's user avatar
5 votes
1 answer
224 views

What prevents a List(Of T) from throwing an arithmetic overflow exception when I set the internal _version field to Integer.MaxValue and add a new item? TL;DR: As you can see when looking at the ...
Bjørn-Roger Kringsjå's user avatar
4 votes
3 answers
317 views

I know this question has been partly answered here on S.O., but there they explain what happens during an arithmetic overflow. And elsewhere on S.O. they explain how to check for overflow in java code,...
knb's user avatar
  • 9,483
3 votes
1 answer
1k views

I'm getting this error System.OverflowException: Arithmetic operation resulted in an overflow. when i ran my application on Windows Server 2008 R2 Standard compiled in .Net 2.0 or greater (.Net 4.0). ...
user1576055's user avatar
1 vote
0 answers
35 views

My question here is in terms of concept. Background Donald Knuth once mentioned about a case where sometimes his merge sort failed once in a while. Later on he found out that it's due to the maximum ...
Iwan Satria's user avatar
  • 2,213