You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2006/05/17 08:27:06 UTC
[jira] Commented: (MATH-60) [math] Function
math.fraction.ProperFractionFormat.parse(String, ParsePosition) return
illogical result
[ http://issues.apache.org/jira/browse/MATH-60?page=comments#action_12412099 ]
Phil Steitz commented on MATH-60:
---------------------------------
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. Otherwise, we have to disambiguate expressions such as "-1 -1/3" which could mean -4/3 or -2/3. I think it is better to view these expressions as meaningless. If there are no objections, I will make that change.
> [math] Function math.fraction.ProperFractionFormat.parse(String, ParsePosition) return illogical result
> -------------------------------------------------------------------------------------------------------
>
> Key: MATH-60
> URL: http://issues.apache.org/jira/browse/MATH-60
> Project: Commons Math
> Type: Bug
> Versions: 1.1 Final
> Environment: Operating System: other
> Platform: Other
> Reporter: nhung.nnguyen
>
> Hello,
> I find illogical returned result from function "Fraction parse(String source,
> ParsePostion pos)" (in class ProperFractionFormat of the Fraction Package) of
> the Commons Math library. Please see the following code segment for more
> details:
> "
> ProperFractionFormat properFormat = new ProperFractionFormat();
> result = null;
> String source = "1 -1 / 2";
> ParsePosition pos = new ParsePosition(0);
> //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 provide invalid numerator/denominator.
> Thank you!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org