When does java print Infinity and when does it print NaN?
Why is 1.0/0.0 infinity but ((1.0/0.0) - (1.0/0.0)) NaN and 0.0f/0.0f an NaN?
What is the difference between these two?
NaN (Not a Number) is a numeric data type that means an undefined value or value that cannot be represented, especially results of floating-point calculations.
Contents. INF ("infinity"), NAN ("not a number"), and Null are special-valued system constants that Analytica returns in particular conditions, such as exceptions. These constants can also be used as values in expressions. An indeterminant number, which is a numeric value that is not well-defined, such as 0/0 .
Inf and -Inf are positive and negative infinity whereas NaN means 'Not a Number'. (These apply to numeric values and real and imaginary parts of complex values but not to values of integer vectors.) Inf and NaN are reserved words in the R language.
For those who are unfamiliar with the notation of inf and NaN , they stand for infinity and Not-a-Number , respectively. Even though infinity can be thought of as an extremely very large number, it has no end. We can define the negative infinity as -inf and the positive infinity as inf in Python.
Because Java is following known math facts. 1.0 / 0.0 is infinity, but the others are indeterminate forms, which Java represents as NaN
(not a number).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With