public static boolean sameZero ( Object x , Object y ) { if ( ! typeof ( x ) . equals ( typeof ( y ) ) ) { return false ; } if ( x instanceof Number ) { if ( isNaN ( x ) && isNaN ( y ) ) { return true ; } final double dx = ( ( Number ) x ) . doubleValue ( ) ; if ( y instanceof Number ) { final double dy = ( ( Number ) y ) . doubleValue ( ) ; if ( ( ( dx == negativeZero ) && ( dy == 0.0 ) ) || ( ( dx == 0.0 ) && dy == negativeZero ) ) { return true ; } } return eqNumber ( dx , y ) ; } return eq ( x , y ) ; }
Implement SameValueZero from ECMA 7 . 2 . 9