This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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.
Have you checked out Aspose?
subject: floating point division
It's not a secret anymore!