Linked Questions
15 questions linked to/from Why don't languages raise errors on integer overflow by default?
23
votes
2
answers
5k
views
Why doesn't C# use arithmetic overflow checking by default? [duplicate]
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 ...
3
votes
2
answers
831
views
Why does assigning an a value greater than an int to an int not throw an exception by default? [duplicate]
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 ...
1
vote
0
answers
55
views
Why do we allow overflow by default? [duplicate]
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 ...
278
votes
12
answers
223k
views
How does Java handle integer underflows and overflows and how would you check for it?
How does Java handle integer underflows and overflows?
Leading on from that, how would you check/test that this is occurring?
9
votes
3
answers
3k
views
Why in LISP , there is no limitation for number?
I can even calculate (expt 32768 32768) and I got:
...
8
votes
6
answers
2k
views
Why does C# let me overflow without any error or warning when casting an Int64 to an Int32 and how does it do the cast?
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 ...
12
votes
6
answers
6k
views
Python: Is there a way to keep an automatic conversion from int to long int from happening?
Consider the example:
>>> from sys import maxint
>>> type(maxint)
<type 'int'>
>>> print maxint
9223372036854775807
>>> type(maxint+2)
<type 'long'>
>...
10
votes
4
answers
2k
views
Why, In Java arithmetic, overflow or underflow will never throw an Exception?
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 ...
5
votes
2
answers
2k
views
How does arithmetic overflow checking work in c#
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 /...
8
votes
2
answers
1k
views
Why do integer datatypes overflow silently rather than throwing exception
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 ...
0
votes
1
answer
2k
views
Why don't I get an exception on integer (uint) under/overflow? [duplicate]
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;
...
5
votes
1
answer
224
views
List(Of T) saved by unknown hero?
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 ...
4
votes
3
answers
317
views
Arith Overflows in java: why there are no exceptions at run time and no compiler warnings?
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,...
3
votes
1
answer
1k
views
Arithmetic overflow exception in .net 2.0 and greater
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). ...
1
vote
0
answers
35
views
Why doesn't java throw overflow error when maximum value is exceeded [duplicate]
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 ...