What does signed mean? Remember from our bit and binary class that sign means it has a +/- sign. Unsigned means it is like a raw value
0-positive
1-negative
Lets say we are comparing 32 bit.
Signed needs to allocate 1 bit to the sign. So the remaining bit we have is 31. So max value of signed 32 bit int is 2^31 -1. There is -1 cuz we want the same range of max positive and min negative number.
For positive, we are including 0 so we have to -1 cuz negative doesnt include 0. Instead for negative, it starts from -1. So the min value of signed int is -2^31. There is no -1 cuz of the range as mentioned.
Unsigned is from 0 to 2^32-1. Why minus 1? 0 is either 00000000 or 10000? I didnt know the latter can be represented as 0. So we cant have 1000000000. OHHHHHHH that is cuz the MSB shows the sign and if it is 1 then it is negative. But i thought unsigned doesnt have sign.
So
Instead we need to have 011111111.
0 is either 00000000 or 10000? I didnt know the latter can be represented as 0.