Affects Version/s: 1.2
Fix Version/s: 2.0
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
Eclipse Ganymede 3.4.1
I've improved and extended the Fraction class for my personal needs, but it could be nice to incorporate it within the commons-math library., either by modifying the current Fraction class, or by creating a new class which could be called AdvancedFraction or something like that. I've tried to keep all features from the original Fraction class.
New features :
- I needed to avoid overflow problem. As a result, I've changed numerator and denominator to BigInteger and all associated methods / constructors.
- I've also added other methods and static fields such as :
- I've made sure that the original Junit test within the FractionTest class are all right (I've just commented the overflow tests)
- I've made sure that checkstyle is all right without any tabs
Obviously, some things need to be reworked or improved :
- Some methods are still naively implemented, such as
because I don't have converted the original private Fraction addSub(Fraction fraction, boolean isAdd) method.
- The original private Fraction(double value, double epsilon, int maxDenominator, int maxIterations) constructor may use BigDecimal instead of double. I'm not sure it is relevant.
- Junit tests have to be written with news methods (such as pow)
- Some minor adaptations have to be done in the FractionFormat class (change getDenominator() by getDenominatorAsInt() for instance)
You'll find my work in the attached zip file :
- The Fraction and FractionTest classes
- The javadoc generated with public and private fields and methods (to show you a complete overview)