Back

Explore Courses Blog Tutorials Interview Questions
+13 votes
4 views
in Java by (1k points)
I am running a program in java, it is giving an unexpected output.

The output is Nan, what  does is it mean ?

2 Answers

+13 votes
by (13.2k points)

The NaN property means a  "Not-a-Number" value. This property tells us that a value is not a legal number.

When there is an operation to produce some undefined result,Nan is produced. For example, any number divided by 0.0 is arithmetically undefined.Also, the square root of a negative number is also undefined in maths, so it is Nan.

According to IEEE 754, there are two types of NaN: quiet and signaling.

+2 votes
by (108k points)
edited by

"NaN" stands for "not a number".

"Nan" is created if a computer operation has input parameters that generate the procedure to create some indefinable result.

Get a detailed understanding of Java from scratch! Refer to this video provided by Intellipaat:

For example, 0.0 divided by zero.0 is arithmetically indefinable.

Taking the root of a negative number is also indefinable.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 18, 2019 in Data Science by ashely (50.2k points)
0 votes
1 answer

Browse Categories

...