Results 1 to 6 of 6
  1. #1
    buzbee is offline Member
    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Default Interger.minValue & maxValue

    Hi Everyone,

    apologies if this is in the wrong section but i am new to java and I am looking to understand it more.

    I have a question about the min and max integer values that are in java.

    I have found the absolute integer values of each being -2^31 for the min value and 2^31 -1 for the max value.

    my question is this: if I go one below the min value and one above the max value should i get an error message and what error message if any would i get ?

    any help about this would be great

    Thanks!

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Interger.minValue & maxValue

    What happened when you've tried? You certainly won't blow up you computer.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    buzbee is offline Member
    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Default Re: Interger.minValue & maxValue

    Thanks for the reply,

    Its an exam question i found that asks what is the output from going one below the minvalue and one above the maxvalue.
    I was always under the impression that an error would occur as it has set its limit (min value /max value) and you could extend past that.

    I have ran some code in Spring source to see what happens and when i have add 1 to the maxValue and the output i get is: -2147483648

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Interger.minValue & maxValue

    There you go, no error or exception. What you've seen is called an overflow. If you exceed the limit you end up at the other end of the range.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    buzbee is offline Member
    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Default Re: Interger.minValue & maxValue

    Thanks for your help.

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Interger.minValue & maxValue

    You're welcome.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Insert interger
    By yuslaidi in forum JDBC
    Replies: 6
    Last Post: 03-14-2011, 04:53 PM
  2. convert interger value to binary value
    By ahmed80 in forum New To Java
    Replies: 6
    Last Post: 01-21-2011, 12:26 PM
  3. trying to convert an interger to a string
    By matpj in forum New To Java
    Replies: 12
    Last Post: 01-15-2009, 11:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •