commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <>
Subject Re: [math] add Complex.toString() and Howto handle NaN values properly
Date Tue, 12 Jul 2011 14:24:00 GMT

> I try to add the method toString() to Complex.

I've created an issue for this:
With the "ComplexFormat" class, the "toString" method should be trivial to
add to the "Complex" class.
[This is already done in my working copy of the code.]
Please, let me know whether you agree with what I propose in the issue's

> There some issues arise:
> If ether the real or imaginary part is NaN hashCode() will return the
> same value. Complex.toString() should return Double.valueOf(Double.NaN).
> Is thee a need to store the given values of the real/imaginary part? or
> set both to Double.NaN in the constructor?
> Maybe drop the constructor completely, make createComplex(...) public
> and return in this case Complex.NaN which is then the marker for NaN
> values?

I don't understand how this affects the code of a "toString" method.

> the methods add/subtract handle NaN values different one will return
> Complex.NaN the other will calculate the result and result.isNaN() ==
> true. This makes in my opinion no sense, because result.hashCode() ==
> Complex.NaN,hashCode()...

This is not clear to me.
Please write different posts for different issues.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message