Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1395

MathParseException when parsing fractions on Android

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      I'm seeing a strange issue when trying to work with the Fraction classes on Android. In my tests, which are standard JUnit tests, the following code performs flawlessly;

      String amount = "1 1/2";
      ProperFractionFormat ff = new ProperFractionFormat();
      Fraction f = ff.parse(amount.trim());
      

      However, at run time in an Android application, the same code throws an Exception:

                         Caused by: org.apache.commons.math3.exception.MathParseException: illegal state: string "1 1/2" unparseable (from position 3) as an object of type org.apache.commons.math3.fraction.Fraction
                            at org.apache.commons.math3.fraction.FractionFormat.parse(FractionFormat.java:199)
      

      I am testing on a Nexus 5X emulator with API level 23 for reference.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              brianzable Brian Zable
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: