To check if double is a Not a Number (NaN)

Asked 2 years ago, Updated 2 years ago, 69 views

I want to check if the value of double is NaN in Java, what should I do?

java double equality nan

2022-09-21 17:37

1 Answers

Write the double.isNaN(double) static method.

// 1. static method
if (Double.isNaN(doubleValue)) {
    ...
}
// // 2. object's method
if (doubleObject.isNan()) {
    ...
}


2022-09-21 17:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.