1. What do these three special floating-point values mean: positive infinity, negative infinity, NaN? stackoverflow.comHow 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.comNote: Similar to C++ can int be NaN?
I understand this has little practical purpose, but can a |
3. Float.NaN question coderanch.comHi, 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 ... |