File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Floating Point Number and dividebyzero arithmatic exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Floating Point Number and dividebyzero arithmatic exception" Watch "Floating Point Number and dividebyzero arithmatic exception" New topic
Author

Floating Point Number and dividebyzero arithmatic exception

veer jain
Greenhorn

Joined: Mar 19, 2008
Posts: 5
Why does the Floating Point numbers does NOT produce the dividebyzero arithmatic exception ??



The above code runs fine, But Why ?? Why is it designed like that ?? It should through an exception...

Any Thgoughts ?

Regards
Veer
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1779
    
    7

Because IEEE 754 specifies that division by zero for floating point numbers should result in either positive or negative infinity depending on the sign bit.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Gitesh Ramchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 274
* if the value of the divisor in floating-point division is 0 no exception is thrown; the value of the results are as follows:
o division of a positive floating-point value: POSITIVE_INFINITY
o division of a negative floating-point value: NEGATIVE_INFINITY
o division of a floating-point value by -0: POSITIVE_INFINITY

veer jain
Greenhorn

Joined: Mar 19, 2008
Posts: 5
Thanks a ton Guys !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Floating Point Number and dividebyzero arithmatic exception