Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: need help..

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default need help..

    can someone explain how does the range for int comes out to be -231 to (231-1)...i mean , we can also fit 231 inside this range....???? why -1 ????

  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: need help..

    Welcome datus
    0 offset the balance on the positive side

  3. The Following User Says Thank You to jps For This Useful Post:

    datus (August 11th, 2013)

  4. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: need help..

    Read about 2's compliment
    Improving the world one idiot at a time!

  5. The Following User Says Thank You to Junky For This Useful Post:

    jps (August 11th, 2013)

  6. #4
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: need help..

    Hello.
    Java uses 2's complement representation for storing numbers.
    And an integer occupies 4 bytes of memory.
    With this much knowledge just spend some time on how to store signed numbers using 2's complement. You should be able to get the range.

    Syed.