Monday, November 9, 2009

When is -1/4 not equal to -1/4?

Got this today as the first line of an assertion failure trace in

junit.framework.AssertionFailedError: expected:<-1/4> but was:<-1/4>

This was produced by the following assertion:

assertEquals("-1/4", oneFourth.subtract(oneHalf));

The fields oneFourth and oneHalf are instances of a Rational class I'm working on.

I must be missing something obvious.

No comments: