public static boolean equal(Number lhs, Number rhs) {
        Class lhsClass = lhs.getClass();
        Class rhsClass = rhs.getClass();
        assert lhsClass != rhsClass;

        if (isDoubleRepresentable(lhsClass)) {
            if (isDoubleRepresentable(rhsClass)) {
                return equalDoubles(lhs.doubleValue(), rhs.doubleValue());
            } else if (isLongRepresentable(rhsClass)) {
                return equalLongAndDouble(rhs.longValue(), lhs.doubleValue());
            }
        } else if (isLongRepresentable(lhsClass)) {
            if (isDoubleRepresentable(rhsClass)) {
                return equalLongAndDouble(lhs.longValue(), rhs.doubleValue());
            } else if (isLongRepresentable(rhsClass)) {
                return lhs.longValue() == rhs.longValue();
            }
        }

        return lhs.equals(rhs);
    }
public static boolean equal ( Number lhs , Number rhs ) { Class lhsClass = lhs . getClass ( ) ; Class rhsClass = rhs . getClass ( ) ; assert lhsClass != rhsClass ; if ( isDoubleRepresentable ( lhsClass ) ) { if ( isDoubleRepresentable ( rhsClass ) ) { return equalDoubles ( lhs . doubleValue ( ) , rhs . doubleValue ( ) ) ; } else if ( isLongRepresentable ( rhsClass ) ) { return equalLongAndDouble ( rhs . longValue ( ) , lhs . doubleValue ( ) ) ; } } else if ( isLongRepresentable ( lhsClass ) ) { if ( isDoubleRepresentable ( rhsClass ) ) { return equalLongAndDouble ( lhs . longValue ( ) , rhs . doubleValue ( ) ) ; } else if ( isLongRepresentable ( rhsClass ) ) { return lhs . longValue ( ) == rhs . longValue ( ) ; } } return lhs . equals ( rhs ) ; }
Checks the provided {@link Number} instances for equality.
<p>
Special numeric comparison logic is used for {@link Double}, {@link Long},
{@link Float}, {@link Integer}, {@link Short} and {@link Byte}: two
values are considered equal, if both represent a number of the same
magnitude and sign, disregarding the actual underlying types.

@param lhs the left-hand side {@link Number}. Can't be {@code null}.
@param rhs the right-hand side {@link Number}. Can't be {@code null}.
@return {@code true} if the provided numbers are equal, {@code false}
otherwise.