wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 1752
    
    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 !!
 
Don't get me started about those stupid light bulbs.
 
subject: Floating Point Number and dividebyzero arithmatic exception
 
Similar Threads
division by zero
constructor - help needed
floating point value
My program won't return the correct ammount of change
Arithmatic Exception