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 Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "floating point division" Watch "floating point division" New topic

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.
It is sorta covered in the JavaRanch Style Guide.
subject: floating point division