Top "Integer-overflow" questions

Integer overflow occurs when the result of an operation is larger than the maximal value that can be represented by the underlying integer type.

Panicked at 'attempt to subtract with overflow' when cycling backwards though a list

I am writing a cycle method for a list that moves an index either forwards or backwards. The following code …

rust integer-overflow integer-arithmetic
Overflowing of Unsigned Int

What will the unsigned int contain when I overflow it? To be specific, I want to do a multiplication with …

c++ integer-overflow unsigned-integer
How do I detect overflow while multiplying two 2's complement integers?

I want to multiply two numbers, and detect if there was an overflow. What is the simplest way to do …

algorithm overflow integer-overflow twos-complement
Checking for underflow/overflow in C++?

Is there a general way to check for an overflow or an underflow of a given data type (uint32, int …

c++ overflow integer-overflow underflow
Java Integer compareTo() - why use comparison vs. subtraction?

I've found that java.lang.Integer implementation of compareTo method looks as follows: public int compareTo(Integer anotherInteger) { int thisVal = …

java optimization integer comparison integer-overflow
Can XOR of two integers go out of bounds?

I had been studying the algorithm for finding lonely integers in an array, and here is the implementation: int arr[] = {10, 20, 30, 5, 20, 10, 30}; …

c++ c bit-manipulation integer-overflow bitwise-xor
Often big numbers become negative

Since I started using eclipse for project euler, I noticed that big numbers sometime become a seemingly random negative numbers. …

java biginteger integer-overflow
Incrementing an integer value beyond its integer limit - C#

I've a for loop which keeps incrementing an integer value till the loop completes. So if the limit n is …

c# integer-overflow
If a 32-bit integer overflows, can we use a 40-bit structure instead of a 64-bit long one?

If, say, a 32-bit integer is overflowing, instead of upgrading int to long, can we make use of some 40-bit …

c++ c memory-management integer-overflow
At what point in the loop does integer overflow become undefined behavior?

This is an example to illustrate my question which involves some much more complicated code that I can't post here. #…

c++ c undefined-behavior integer-overflow