osglworks / java-tool

Some simple common Java utilities
Apache License 2.0
52 stars 18 forks source link

N.eq's bug #237

Closed moonmanbu closed 3 years ago

moonmanbu commented 4 years ago
    public static final boolean eq(Number a, Number b) {
        if (null == a) {
            return null == b;
        }
        if (null == b) {
            return false;
        }
        return (a.doubleValue() - b.doubleValue()) <= Double.MIN_NORMAL;
    }
return (a.doubleValue() - b.doubleValue()) <= Double.MIN_NORMAL;

应当为

return Math.abs(a.doubleValue() - b.doubleValue()) <= Double.MIN_NORMAL;

否则如果负数结果是错的