Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Floating Point Number and dividebyzero arithmatic exception

 
veer jain
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gitesh Ramchandani
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
* 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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a ton Guys !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic