Is the any way one can represent a very large number in java.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thatos
    New Member
    • Aug 2007
    • 105

    #1

    Is the any way one can represent a very large number in java.

    I'm trying to write an algorithm which determines the shortest path between cities. So I have looked at some high level languages of the algorithms, if the is no path between two vertices, they represent this by infinity, is there any way I could represent a very large number in java?
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    What type are you using to represent distance? Consider:

    Integer.MAX_VAL UE

    or

    Double.POSITIVE _INFINITY

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      For those 'big M' values usually no large numeric values are used. Sentinel
      values such as -1 do a better job.

      kind regards,

      Jos

      Comment

      Working...