It is not possible in regular mathematics to get a value for the square-root of a negative number therefore a NaN will be returned because the code is valid.
NaN stands for "Not a Number". Math.sqrt() function can only handle positive numbers, and square root of negative numbers is not defined (its a complex number and Java doesn't provide much support for complex numbers) , so it prints NaN.
Ranjitha said:
(Oct 27, 2017)
Thank you @Jbxquu.
Pramit said:
(Jun 14, 2018)
What is D here?
Post your comments here:
Name *:
Email : (optional)
» Your comments will be displayed only after manual approval.