Range of integer


#1

<wht the range of the integer number is between -2,147,483,648 and 2,147,483,647>



Replace this line with your code. 



#2

Because integers are signed (they have a - or + sign) the largest positive integer is 2 ** 31 - 1 and the smallest negative is - (2 ** 31 - 1) - 1. In other words, 31 bits plus a sign bit.

Read up on two's complement and negative numbers.

# python
>>> bin(0 ^ (2 ** 32 -1))
'0b11111111111111111111111111111111'

It’s a lot of 1’s, but that is the 32 bit representation of -1.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.