Java: NaN
Go to solution
Solved by Blade of Grass,
3 minutes ago, mikestechs said:Yes it is. But how can i do--- if result is NaN that the program will say System.out.println("Impossible to do");
System.out.println((Double.isNaN(1.0) ? "Impossible to do" : 1.0));
Not too sure exactly what you want, but Double.isNaN is a static method which returns a boolean value, so use it as a parameter in an if statement, ternary, etc.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now