0

How floating point numbers are represented in memory in JAVA?

As int i=10/0 give divide by zero exception but double d= 10/0.0 gives infinity. So, internally how infinity is represented in double in JAVA?

10th Jun 2018, 8:03 PM
Nikhil Sharma
Nikhil Sharma - avatar
1 Answer
0
floating point numbers in java are represented in the IEEE457 standard (as in any other languages). when dividing with integers, it can't divide by 0, because of the way a computer divides numbers doesn't allow an integer to hold the result. however, floats can hold infinity, -infinity and even values considered not to be numbers, so there's no need for an exception to be raised.
11th Jun 2018, 2:46 PM
hinanawi
hinanawi - avatar