What is the minimum value of a 32-bit signed integer, happens to be the security "challenge" question in order to make an account at [this website](edit: link is now malware) (don't judge I'm just curious and bored).
I assumed they were talking about a typical 32bit int which can store numbers as big as 2,147,483,647
. But when I tried -2147483647
it said I got the question wrong. I tried several variations such as -2,147,483,647
but nothing works...
Am I misinterpreting the question or is there something wrong with the web site?
PS I also tried -2,147,483,648 as suggested
Here's a picture
The most used size of an integer is 32 bits. The last bit is used to distinguish positive and negative numbers. If the last bit is NOT set, then the number is positive. Therefore, the maximal positive number is 0x7FFFFFFF
= (1<<31)-1
=2147483647
(the last bit is not set).
For the negative numbers, two's complement notation is widely used. You can identify the counterpart of the positive number by inverting its all bits and adding 1. Thus, the counterpart for the maximal integer is 0x80000001
, however it is NOT the minimal number.
The minimal number in two's complement notation is 0x80000000
= -2147483648
.
The interesting fact about this number is that it is equal to its own complement, i.e. inverting all bits results in 0x7FFFFFFF
and adding 1 yields 0x80000000
, which is equal to the original number.
More about two's complement notation in wikipedia.
Signed 32 bit integers can go down to -2,147,483,648
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With