Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# why dividing by 0.0 ( float ) dont give ArithmeticException

amit taneja
Ranch Hand
Posts: 813
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
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
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
Thanx a ton,

regards,
amit