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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "float 12.0/0 error" Watch "float 12.0/0 error" New topic
Author

float 12.0/0 error

mridul makkar
Greenhorn

Joined: Feb 15, 2005
Posts: 14
Why float f=12.0/0 wont raise any exception.I want to know the inner reason......
Jay Pawar
Ranch Hand

Joined: Aug 27, 2004
Posts: 411
Check out this link . Hope this helps you.


Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
vas vas
Greenhorn

Joined: Dec 13, 2004
Posts: 19
Hi,

Unlike Integer class in java, Float has a field called NaN. A constant holding a Not-a-Number value of type float.

so when you do 12.0/0 , this is NaN.This is not the same with integers.You get an exception when you do 12/0 , but not whne 12.0/0.

Hope this helps.
Suman Tedla.
Joe Borderi
Ranch Hand

Joined: Oct 23, 2004
Posts: 151
"so when you do 12.0/0 , this is NaN."

12.0/0 is POSITIVE_INFINITY. NaN results from performing Java operations that result in "Not a Number", such as taking the square root of a negative number.

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Is this even same for double ?
I mean does double has a NAN const.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Jesse Torres
Ranch Hand

Joined: Mar 25, 2004
Posts: 985
Originally posted by srini vasan:
Is this even same for double ?
I mean does double has a NAN const.


Yes primitive double also has a NaN constant.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Thanks guys nice info.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: float 12.0/0 error