Int data type
Int data type
int (1 sign bit + 31 data bits) keyword in C.
it is used to define any positive or negative integer.
According to Min, the size of int is 4 bytes which is equal to 32 bits
1 byte = 8 bits
Integer is not int
integer is a very very category of numbers whereas one 'int' has limited and exact amount of memory to store what is being represented by it.
An int type variable in C is able to store only numbers till 2147483647.
Int is a 32-bit data type when never a number is being assigned to an int type variable it is first converted to its binary representation (that is in 0's and 1's) that it is kept in memory at a specific location.
An int is actually 1 sign bit + 31 data bits, that 31 bits are available for storing the number.
1 bit is represented for maintaining the sign of the number which is either + or - sign is also represented by binary digits
0-> +, 1-> -
int num= 2147483647 will be converted in binary
=11111111111111111111111111111111
31 digits assigned to 31 bits
32nd bit will be a zero(0) or (+)
Unsigned
unsigned int variable_name;
with such a declaration, the range of permissible integer values will shift from the range -32768 to +32767 to the 0 to 65535.
Thus declaring an integer as unsigned almost doubles the size of the largest possible value that it can otherwise take.
This happens because on declaring the integer as unsigned, the left must bite is now free and is not used to store the sign of the number.