public static boolean nanSafeEqualsDoubles(Double d1,Double d2){
  Boolean xIsNan=Double.isNaN(d1);
  Boolean yIsNan=Double.isNaN(d2);
  if ((xIsNan && yIsNan) || (d1.doubleValue() == d2.doubleValue())) {
    return true;
  }
  return false;
}

public static boolean nanSafeEqualsDoubles ( Double d1 , Double d2 ) { Boolean xIsNan = Double . isNaN ( d1 ) ; Boolean yIsNan = Double . isNaN ( d2 ) ; if ( ( xIsNan && yIsNan ) || ( d1 . doubleValue ( ) == d2 . doubleValue ( ) ) ) { return true ; } return false ; }
this method will compare double values for its equality and also it will preserve the - 0 . 0 and 0 . 0 equality as per = = , also preserve nan equality check as per java . lang . double . equals ( )
