Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Infinity

 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println(-1 * Double.NEGATIVE_INFINITY);
prints infinity. What is happening here?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thiru Thangavelu:
System.out.println(-1 * Double.NEGATIVE_INFINITY);
prints infinity. What is happening here?

Why wouldn't it?
 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean, (-1) * (-)infinity = infinity.
i.e
(-) * (-) = (+)
It is same like other mathematical calcultations. Am i right?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. In mathematics, if you multiply a value by -1, you simply flip the sign of that value.
 
Francisco A Guimaraes
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same will happen if you do this:
Math.pow(Double.NEGATIVE_INFINITY,2)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic