GET EDUCATE

Contents
Basics of C Programming

⯈Basic C Programs

Integer Representation in C

Integers in C can be thought as a circle of values. The values go from 0 to 231 -1 and -1 to (- 231 ).

We will discuss integer overflow at the end of this page.

You may watch the video posted at the end of this page.

integer number representation

The integer values go from 0 to maximum value of 231-1 and to minimum value of -231

Integer Overflow

If we try to store the value greater than maximum value (231-1), then the integer overflow takes place.

Ex:

int a = 2147483647;  (231-1)

int b = a + 1;

We cannot store the value greater than (231-1), then integer overflow happens and b = -2147483648 (-231)


If we try to store the value lesser than the minimum value (-231), then also integer overflow happens.

Ex:

int a = -2147483648; (-231)

int b = a – 1;

We cannot store the value less than (-231), integer overflow takes place and b = 2147483647 (231-1)

Scroll to Top