commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C. Scott Ananian" <>
Subject Re: [lang] [math] org.apache.commons.lang.math.Fraction class
Date Sat, 29 May 2004 16:21:25 GMT
On Sat, 29 May 2004, Stephen Colebourne wrote:

> However, we do have to be careful about introducing incompatabilities into
> the class. This Fraction class should follow the 80/20 rule, and maintain
> simplicity when possible. If necessary, a better implementation in the
> commons-math project could then be created. If the incompatability only
> affects fractions with large numerators/denominators then that might be OK
> introducing an incompatability.

The existing add(), subtract(), and multiplyBy() and divide() code (as far
as I can tell) all returned reduced fractions, so existing arithmetic code
should largely be unaffected.  The primary visible difference is that
and now it would be true.
I view the previous behavior as "surprising" and a bug, honestly.

The previous implementation was very dangerous in so far as it could
silently corrupt your fraction due to overflow in its temporary values,
even if the result "should have" fit into an int.  Now these corner cases
have been fixed.  This is what projects like commons promise: robust
implementations of common code where all of the nasty gotchas have been
thought-through and fixed.  I hope that my patch accomplishes this for

> Hopefully the math project crew can review the current implementation and
> patch as well.

It's now bugzilla bug #29294:

The best way to understand the patch is actually to start at the new
junit tests, which identify some of the ways that the old code failed.

MI6 Semtex Rule Psix Noriega FBI Columbia Panama $400 million in gold bullion
NSA Sabana Seca Washington Soviet  Moscow PLO India Dictionary supercomputer
                         ( )

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

View raw message