aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes floating point division Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "floating point division" Watch "floating point division" New topic
Author

floating point division

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100


Why is the output infinity
and not -infinity
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
To get -Infinity you have to use -0.0 as the denominator.

My interpretation of your example is as follows:
-0 is done with integer arithmetic, so -0 -> -(0) -> 0 and that gets converted to 0.0 before the division is done. Therefore (+)Infinity is the result.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
wood burning stoves
 
subject: floating point division