Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 67793 invoked from network); 28 Mar 2009 09:02:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Mar 2009 09:02:15 -0000 Received: (qmail 77478 invoked by uid 500); 28 Mar 2009 09:02:14 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 77370 invoked by uid 500); 28 Mar 2009 09:02:14 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 77360 invoked by uid 99); 28 Mar 2009 09:02:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Mar 2009 09:02:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Mar 2009 09:02:12 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 4EC51234C003 for ; Sat, 28 Mar 2009 02:01:51 -0700 (PDT) Message-ID: <1046519100.1238230911308.JavaMail.jira@brutus> Date: Sat, 28 Mar 2009 02:01:51 -0700 (PDT) From: "Benjamin Croizet (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (MATH-251) Improve the Fraction class to avoid overflow problems and increase features In-Reply-To: <152317981.1238230790456.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Benjamin Croizet updated MATH-251: ---------------------------------- Attachment: NewFraction.zip New _*Fraction*_ class and its javadoc documentation. > Improve the Fraction class to avoid overflow problems and increase features > --------------------------------------------------------------------------- > > Key: MATH-251 > URL: https://issues.apache.org/jira/browse/MATH-251 > Project: Commons Math > Issue Type: Improvement > Affects Versions: 1.2 > Environment: 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) > Windows XP > Eclipse Ganymede 3.4.1 > Reporter: Benjamin Croizet > Priority: Minor > Fix For: 2.0 > > Attachments: NewFraction.zip > > > Hello everybody, > 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. > {color:green}New features :{color} > * 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 : > {code:java} > public String toString() > public Fraction add(int i) > public Fraction subtract(int i) > public Fraction multiply(int i) > public Fraction divide(int i) > public Fraction pow(int exponent) > public double pow(Fraction exponent) > public BigDecimal bigDecimalValue() > public Fraction clone() > public double percentageValue() > public static Fraction ONE_HALF = new Fraction(1, 2) > public static Fraction ONE_QUARTER = new Fraction(1, 4){code} > * 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 > {color:red}Obviously, some things need to be reworked or improved :{color} > * Some methods are still naively implemented, such as > {code:java} > public Fraction add(Fraction fraction) > public Fraction subtract(Fraction fraction) > {code} 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) > Thank you. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.