commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject Re: [numbers/general] unlikely argument type warning
Date Fri, 14 Dec 2018 01:26:35 GMT
On Thu, 13 Dec 2018 11:39:05 -0800, Eric Barnhill wrote:
> For the line:
>
> Assert.assertFalse(zero.equals(Double.valueOf(0)));

What is it testing?
Conceptually, I'd expect "assertTrue" (zero as a fraction
is equal to zero as a double).

>
> Eclipse is producing a warning:
>
> "Unlikely argument type for equals(): Double seems to be unrelated to
> Fraction"
>
> Does anyone have a suggestion for how to handle this warning, thank 
> you.

Perhaps Eclipse indicates that the test is useless (since
"Double" is not a subclass of "Fraction").

And perhaps "Fraction" should overload "equals":

public boolean equals(double x, int ulp) {
    return Precision.equals(doubleValue(), x, ulp);
}
public boolean equals(Number x, int ulp) {
    return equals(x.doubleValue, ulp);
}
public boolean equals(double x) {
    return equals(doubleValue(), x, 1);
}

Gilles

>
> Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message