What is the minimum value of a 32-bit signed integer?
Asked Answered
S

2

22

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 enter image description here

Schell answered 29/9, 2013 at 22:55 Comment(2)
Have you tried -2147483648, or possibly even 0Inexperienced
Did you read the question carefully before entering the number? I noticed it bounces between asking for the maximum and asking for the minimum (hit refresh a few times and watch it change). Make sure you know which one! ;)Hydrocarbon
C
41

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.

Clarance answered 28/7, 2015 at 23:9 Comment(0)
E
9

Signed 32 bit integers can go down to -2,147,483,648

Ersatz answered 29/9, 2013 at 22:58 Comment(6)
Incidentally, when I go to that site, it asks me for the maximum? Is it possible that you read it wrong/it asks a different question each time?Ersatz
I noticed that it changes every few refreshes.Hydrocarbon
I added a picture to answer your questionsSchell
there must be something wrong with the form, it accepts the correct maximum, and I double checked in Java (incase it was something silly like formatting) and this line: System.out.printf("%d", Integer.MIN_VALUE) gives: -2147483648Ersatz
I got it to accept the max value... weird that it didn't work with the min.Schell
email them and tell them the form is broken - I tried, but you have to create an account and login - too much like hard work for me!Ersatz

© 2022 - 2024 — McMap. All rights reserved.