Integer overflow and integer limits

tmp1 = -2*INT_MIN; undefined behaviour unless INT_MAX has twice the magnitude of INT_MIN (it won’t).

tmp2 = 2*INT_MIN; undefined behaviour (overflowing a signed integer)

tmp3 = -2*INT_MAX; undefined behaviour unless INT_MIN has twice the magnitude of INT_MAX (it won’t).

tmp4 = 2*INT_MAX; undefined behaviour (overflowing a signed integer)

temp1 = -2*INT_MIN; undefined behaviour (overflowing a signed integer)

temp2 = 2*INT_MIN; undefined behaviour (overflowing a signed integer)

temp3 = -2*INT_MAX; undefined behaviour (overflowing a signed integer)

temp4 = 2*INT_MAX; undefined behaviour (overflowing a signed integer)

Read more here: Source link