why do we choose only -2^31 as definite value of int_min
Maximum of n numbers
We choose -2^31 as definite value of int_min because it’s the smallest possible value which can be stored in the 4byte integer bucket…
as :
4byte means 32 bits as:
the maximum -ve no. that can be stored in 32bits ===> is -2^31 …
But why -2^31 is minimum lets see…
understand with example:
if we have 4bits then==> (for signed integer:)
here In Memory==> +ve no. is stored in there binary respresentation But -ve no. is stored in form of 2’s complement
so range is from ==> -2^(4-1) to +2^(4-1)-1 (i.e. -8 to 7)
similiarly for 32 bit integer:
range is from : ==> -2^(32-1) to +2^(32-1)-1 (i.e. -2^31 to +2^31-1)
Hence we can take INT_MIN as -2^31 and INT_MAX as +(2^31-1)
I Hope this helps
If you have further doubt feel free to ask