osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]# Re: [numbers/general] unlikely argument type warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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, thankyou.

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@xxxxxxxxxxxxxxxxxx For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxxxx

- Prev by Date:
**Re: [numbers] propose making BigFraction an extension of Fraction** - Next by Date:
**JDK 12 enters Rampdown Phase One** - Previous by thread:
**[numbers/general] unlikely argument type warning** - Next by thread:
**JDK 12 enters Rampdown Phase One** - Index(es):