• Post Reply Bookmark Topic Watch Topic
  • New Topic

postive infinity  RSS feed

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there some int representation I can use for positive infinity?
I need some unique value I can compare to new values (ints) that will always be greater than all other values.
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Elouise, you may want to try this Double.POSITIVE_INFINITY
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While Java doesn't provide an integral bit pattern to represent an infinite value, you might be able to make use of Integer.MAX_VALUE for your problem. Integer.MAX_VALUE is the largest positive value that can be represented by an int data type in Java. Note that a similar value exists for longs - Long.MAX_VALUE.
 
Sheriff
Posts: 9082
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also remember that if you add
Integer.MAX_VALUE + 1
you will end up with a negative number that will be (obviously) less than Integer.MAX_VALUE.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!