We know that cosmetic operations in Java do not allow 0 to be the denominator, but are possible in floating-point operations, so there is a special case of Nan and infinity, both of which are illegal floating-point data. 1.Infinity: The numerator is not 0 the denominator is zero, when doing division produces, represents infinity or infinitesimal number.
Double:
public static final Double positive_infinity = 1.0/0.0;
public static final Double negative_infinity = -1.0/0.0;
Float:
public static final Float positive_infinity = 1.0f/0.0f;
public static final Float negative_infinity = -1.0f/0.0f;
2.NAN: The numerator denominator is zero, the illegal type that occurs when dividing is defined as follows:
public static final Double NaN = 0.0d/0.0;
3. Evasion: in practice, the occurrence of Nan and infinity illegal floating-point types are sometimes not caused by our coding, sometimes because of the call of other people's interface or a large number of data intermediate processing need to do division will inevitably encounter this situation, then we have to think of it to evade, static method that needs to be used to double
Double.isnan (v)
Double.isinfinite (v)