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.

Efficient unsigned-to-signed cast avoiding implementation-defined behavior

I want to define a function that takes an unsigned int as argument and returns an int congruent modulo UINT_…

c++ casting integer language-lawyer integer-overflow
Equivalent of atoi for unsigned integers

I'm doing two operations involving atoi and I'm wondering how I can do this with unsigned integers because atoi seems …

c integer-overflow atoi
why Integer.MAX_VALUE + 1 == Integer.MIN_VALUE?

System.out.println(Integer.MAX_VALUE + 1 == Integer.MIN_VALUE); is true. I understand that integer in Java is 32 bit and …

java integer integer-overflow twos-complement jls
How can I check if multiplying two numbers in Java will cause an overflow?

I want to handle the special case where multiplying two numbers together causes an overflow. The code looks something like …

java math long-integer integer-overflow
How can I detect integer overflow on 32 bits int?

I know such topic was asked several times, but my question is about overflow on full 32 bits of int. For …

java integer bit-manipulation integer-overflow integer-arithmetic
Absolute value of INT_MIN

How could I extract the absolute value of INT_MIN without overflowing? See this code for the problem: #include <…

c int integer-overflow
Why does Java think that the product of all numbers from 10 to 99 is 0?

The following block of codes gives the output as 0. public class HelloWorld{ public static void main(String []args){ int product = 1; …

java integer integer-overflow
Is signed integer overflow still undefined behavior in C++?

As we know, signed integer overflow is undefined behavior. But there is something interesting in C++11 cstdint documentation: signed integer …

c++ c++11 undefined-behavior integer-overflow
Unexpected results when working with very big integers on interpreted languages

I am trying to get the sum of 1 + 2 + ... + 1000000000, but I'm getting funny results in PHP and Node.js. PHP $sum = 0; …

php node.js precision integer-overflow integer-arithmetic
Detecting signed overflow in C/C++

At first glance, this question may seem like a duplicate of How to detect integer overflow?, however it is actually …

c++ c undefined-behavior signed integer-overflow