DoubleINFINITYTest

    SourceCode:

public class DoubleINFINITYTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		double d_negative = -10.0 / 0.0;
		if (d_negative == Double.NEGATIVE_INFINITY) {
		   System.out.println("d_negative : " + d_negative);
		}
		
		double d_positive = 10.0 / 0.0;
		if (d_positive == Double.POSITIVE_INFINITY) {
		   System.out.println("d_positive : " + d_positive);
		}
		
		if (Double.isInfinite(d_negative)) {
		   System.out.println("d_negative : " + d_negative);
		}
		
		if (Double.isInfinite(d_positive)) {
		   System.out.println("d_positive : " + d_positive);
		}
		
		double d_zero = 0.0d / 0.0;
		if (Double.isNaN(d_zero)) {
		   System.out.println("d_zero : " + d_zero);
		}
	}
}

 

   Output:

d_negative : -Infinity
d_positive : Infinity
d_negative : -Infinity
d_positive : Infinity
d_zero : NaN
 

 

你可能感兴趣的:(double)