Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why dividing by 0.0 ( float ) dont give ArithmeticException

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
can any body tell me why dividing by 0.0 ( float ) dont give ArithmeticException ....

i don't find the proper reason in kethy sera book ...



** kethy sera /bert bates is wonderfull book but some info is missing.. i think...


Thanx and regards,
amit
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Floating-point arithmetic -- as defined by the IEEE 754 standards -- provides special values for these situations: Infinity, Negative Infinity, or NaN (for "not a number").


[ January 19, 2005: Message edited by: marc weber ]
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Floating point numbers are based on aproximations to real numbers. When you are doing calculations, this calculations might start making your numbers aproximate to 0, the numbers become every time smaller, but still bigger than 0. When the number cannot be stored because it is too small a gradual undeflow starts to happen... first Java makes an effort to store the number as a denormalized number and when finally nothing can be done it produces a negative o positive 0; that means an underflow.

So, when you are making operations with floats many things might happen and Java do not raise an Arithmetic exception as with Integers when you divide by zero. Because after all, you might have got a zero after another operation which could not calculate the small number you wanted to use and now everything will not fail just because jvm could not calculate the right number.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a ton,

regards,
amit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic