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.

Addition of two chars produces int

I've made a simple program and compiled it with GCC 4.4/4.5 as follows: int main () { char u = 10; char x = 'x'; char …

c++ integer integer-overflow integer-promotion
Why does long long n = 2000*2000*2000*2000; overflow?

long long int n = 2000*2000*2000*2000; // overflow long long int n = pow(2000,4); // works long long int n = 16000000000000; // works Why does the first …

c++ math types literals integer-overflow
How to avoid integer overflow?

In the following C++ code, 32767 + 1 = -32768. #include <iostream> int main(){ short var = 32767; var++; std::cout << var; …

c++ variables integer-overflow
Signed integer overflow: 999999999 * 10 cannot be represented in type 'int' Error

Why is there a runtime error? I made range2 a long long. Code: /*VARIABLES FOR WHILE LOOP*/ long long range1 = 9; …

c integer-overflow cs50
(A + B + C) ≠ (A + C + B​) and compiler reordering

Adding two 32-bit integers can result an integer overflow: uint64_t u64_z = u32_x + u32_y; This overflow can …

c++ c compiler-construction integer-overflow
"Int" multiplication in c++ with "long long" result

I am trying to find the square of a int. My code looks like below: long long sqr=0; int num=77778; …

c++ multiplication integer-overflow long-long
How to compile and run an optimized Rust program with overflow checking enabled

I'm writing a program that's quite compute heavy, and it's annoyingly slow to run in debug mode. My program is …

rust compiler-optimization integer-overflow
How do I get real integer overflows in MATLAB/Octave?

I'm working on a verification-tool for some VHDL-Code in MATLAB/Octave. Therefore I need data types which generate "real" overflows: …

matlab overflow integer-overflow
executing a process with argc=0

Is it possible to execute a process whose argc = 0? I need to execute a program but it is extremely important …

c integer-overflow argv argc
Is it possible to access the overflow flag register in a CPU with C++?

After performing a mathematical operation, for say, multiplying two integers, is it possible to access the overflow flag register in …

c++ assembly flags integer-overflow