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 Tue, 08 Jun 2004 17:58:06 GMT
On Sat, 5 Jun 2004, Phil Steitz wrote:

> The problem is that we do not know what the "working programmers" are
> going to use this class for.  Your view seems to be that "Fraction" should
> really be "RationalNumber" -- so that two equivalent fractions are equal.

Yes.  Scheme has had this numeric class for a long time and it IS what
"working programmers" find useful.

>   The problem is that the class is not named or currently implemented that
> way (in terms of representation and identity).  Representing the fractions
> themselves instead of collapsing immediately to the equivalence classes
> (rational numbers) is more flexible; though as you point out, more care
> has to be taken to prevent overflows and some efficiency in the arithmetic
> operations may be sacrificed as a result.

and the current implementation allows both uses, although it deprecates
the latter (due to its being harder for programmers to use correctly).
It can be un-deprecated at some later time if there is outcry.

> If we just fix the computational bugs in the current implementation, the
> overflow situation should be OK with the arithmetic operations implemented
> as they are now, since they call reduce() before returning results.  We
> may in fact want to add alternative methods that do not reduce returned
> fractions, or that otherwise restrict / control denominators.  While I do
> not have specific use cases in mind, it could be that some
> number-theoretic applications for this sort of thing may exist.

This is always a really bad way to design software.

> The fact that all current operations reduce returned values led me
> initially to agree that it was pointless to maintain the disctinction
> between equivalent fractions.  Thinking about it some more, I am -0 to
> changing Fraction to "RationalNumber."  I think our best path is to start
> by fixing the computational bugs and then see what sorts of applications
> emerge.

I have an application, and I made the changes that decades of scheme
experience have shown to be useful.

Cheney payment Morwenstow milita Sugar Grove security explosives Hager
ASW operation Bejing corporate globalization United Nations Ortega
                         ( )

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

View raw message