You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/05/14 00:08:05 UTC

DO NOT REPLY [Bug 39576] New: - Function "Fraction math.fraction.FractionFormat.parse(String, ParsePosition) " does not handle parsing the numerater properly

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39576>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39576

           Summary: Function "Fraction
                    math.fraction.FractionFormat.parse(String,
                    ParsePosition) " does not handle parsing the numerater
                    properly
           Product: Commons
           Version: 1.1 Final
          Platform: Other
               URL: http://jakarta.apache.org/commons/math/apidocs/org/apach
                    e/commons/math/fraction/FractionFormat.html#parse(java.l
                    ang.String,%20java.text.ParsePosition)
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Math
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: nhung.nnguyen@gmail.com
OtherBugsDependingO 1,2,5,8
             nThis:


Hello,

While testing function "Fraction math.fraction.FractionFormat.parse(String, 
ParsePosition) ", I found it did not handle properly the case the input string 
passed in is incorrect. 

When I passed in a String that represented a Fraction to be parsed, if the 
Fraction embedded in the String had a whole value, while either the numerator 
or denominator had the negative sign, the function just returned 
1/abs(denomitator).

Please see the following code segment for more details:

"   
  NumberFormat nf = null; 
  
  FractionFormat properFormat = FractionFormat.getProperInstance
(Locale.getDefault());
  FractionFormat improperFormat = FractionFormat.getImproperInstance
(Locale.getDefault());
 
//Test 1 : fail 
public void testParseNegative(){
 
   String source = "1 -2 / 3";
   ParsePosition pos = new ParsePosition(0);

   Fraction actual = properFormat.parse(source, pos);
   assertNull(actual);
}

// Test2: success
public void testParseNegative(){
 
   String source = "1 -2 / 3";
   ParsePosition pos = new ParsePosition(0);

   Fraction actual = properFormat.parse(source, pos);  // return Fraction 1/3
   assertEquals(1, source.getNumerator());
   assertEquals(3, source.getDenominator());
}

"

Note: Similarly, when I passed in the following inputs: 
  input 2: (source = �1 2 / -3�, pos = 0)
  input 3: ( source = � -1 -2 / 3�, pos = 0)

Function "Fraction parse(String, ParsePosition)" returned Fraction 1/3 (means 
the result Fraction had numerator = 1 and  denominator = 3)for all 3 inputs 
above.
 
I think the function does not handle parsing the numberator/ denominator 
properly incase input string provides negative numerator or negative 
denominator while there is the whole value.

Thank you!
Nhung

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 39576] - [math] Function "Fraction math.fraction.FractionFormat.parse(String, ParsePosition) " does not handle parsing the numerater properly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39576>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39576





------- Additional Comments From phil@steitz.com  2006-05-16 03:56 -------
Thank you for reporting this.  I agree that the treatment of minus signs in the
fractional parts of mixed fractions is not correct.  I think, however, that the
correct solution is to throw a ParseException when the fractional part is
negative. If there are no objections, I will make that change.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 39576] - [math] Function "Fraction math.fraction.FractionFormat.parse(String, ParsePosition) " does not handle parsing the numerater properly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39576>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39576


phil@steitz.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Function "Fraction          |[math] Function "Fraction
                   |math.fraction.FractionFormat|math.fraction.FractionFormat
                   |.parse(String,              |.parse(String,
                   |ParsePosition) " does not   |ParsePosition) " does not
                   |handle parsing the numerater|handle parsing the numerater
                   |properly                    |properly




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org