Special floating-point values. : float « Java Source And Data Type « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Java Source And Data Type » float 
1.11.5.Special floating-point values.
Constant                    Interpretation                          Corresponding String

Float.MAX_VALUE             The largest number representable        3.40282e+038

Float.MIN_VALUE             The smallest number representable       1.4013e-045

Float.NEGATIVE_INFINITY     Negative divided by zero                -Infinity

Float.POSITIVE_INFINITY     Positive divided by zero                Infinity

Float.NaN                   Not a Number                            NaN


NaN stands for Not a Number

Float.NaN
Float.NEGATIVE_INFINITY
Float.POSITIVE_INFINITY
Double.NaN
Double.NEGATIVE_INFINITY
Double.POSITIVE_INFINITY

public class MainClass {

  public static void main(String[] a) {
    double d = -10.0 0.0;
    if (d == Double.NEGATIVE_INFINITY) {
      System.out.println("d just exploded: " + d);
    }
  }
}
1.11.float
1.11.1.The two floating-point types are float and double
1.11.2.A floating-point literal with a decimal point
1.11.3.A floating-point literal with letter E or e (scientific notation)
1.11.4.A floating-point literal with suffix F or f, indicating a float literal
1.11.5.Special floating-point values.
1.11.6.Two NaN values are defined in the java.lang package (Float.NaN and Double.NaN)
1.11.7.NaN values are non-ordinal for comparisons.
1.11.8.Use Float.isNaN(float) or Double.isNaN(double) to check NaN value
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.