# NAN « float « Java Data Type Q&A

### 1. What do these three special floating-point values mean: positive infinity, negative infinity, NaN?    stackoverflow.com

How can we use them in our codes, and what will cause NaN(not a number)?

### 2. Can float (or double) be set to NaN?    stackoverflow.com

Note: Similar to C++ can int be NaN? I understand this has little practical purpose, but can a `float` or `double` be set to `NaN`?

### 3. Float.NaN question    coderanch.com

Hi, public static void main(String[] args) throws Exception { if (Float.NaN > Float.POSITIVE_INFINITY) { System.out.println("Float.NaN is greater"); } else { System.out.println("Float.POSITIVE_INFINITY is greater"); } if (Float.POSITIVE_INFINITY > Float.NaN) { System.out.println("Float.POSITIVE_INFINITY is greater"); } else { System.out.println("Float.NaN is greater"); } if(Float.POSITIVE_INFINITY == Float.NaN) { System.out.println("both are equal"); } else { System.out.println("both are NOT equal"); } System.out.println(Float.NaN == Float.NaN); } The above code ...