Harmony
  1. Harmony
  2. HARMONY-6339

[classlib] [math] Sample test case showing Math differences

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0M12
    • Component/s: Classlib
    • Labels:
      None

      Description

      Below is a simple test case which works in the Sun Java 1.5 but fails in Harmony.

      This is derived from the HyperGeometricDistribution test, but is hopefully a bit easier to debug.

      import org.apache.commons.math.util.MathUtils;

      public class HarmMath {

      private static void bcl(int m, int x, double exp)

      { final double logmx = MathUtils.binomialCoefficientLog(m, x); System.out.println(m+","+x+"="+logmx+" "+(logmx==exp?" == ":" != ")+" "+exp); }

      public static void main(String[] args) {
      int[][]mk={{101,84},

      {101,83}

      ,

      {101,60}

      ,

      {101,18}

      ,{101,17}};
      double[]r=

      {43.52547252799755,45.065917568944705,65.69211086727145,45.065917568944705,43.52547252799755}

      ;
      for(int j=0; j<mk.length;j++)

      { bcl(mk[j][0],mk[j][1],r[j]); }

      }

      }

      The cases 101,83; 101,60; and 101,18 generate different results on Harmony.

        Issue Links

          Activity

          Hide
          Tim Ellison added a comment -

          Additional tests committed at r814698.

          Show
          Tim Ellison added a comment - Additional tests committed at r814698.
          Hide
          Tim Ellison added a comment -

          Invalid code reverted, and simple test case added, at repo revision r814620.

          Please verify this fixes the issue.

          Show
          Tim Ellison added a comment - Invalid code reverted, and simple test case added, at repo revision r814620. Please verify this fixes the issue.
          Hide
          Sebb added a comment -

          Indeed - the maximum floor is now Long.MAX_VALUE ... no wonder Commons Math has some problems.

          Seems to me that the Math test cases need enhancing; this should have been discovered when the patch was first tried.

          Show
          Sebb added a comment - Indeed - the maximum floor is now Long.MAX_VALUE ... no wonder Commons Math has some problems. Seems to me that the Math test cases need enhancing; this should have been discovered when the patch was first tried.
          Hide
          Tim Ellison added a comment -

          Looks like a regression introduced by HARMONY-5478.

          Show
          Tim Ellison added a comment - Looks like a regression introduced by HARMONY-5478 .
          Hide
          Tim Ellison added a comment -

          Math.floor(3.7314645675925406E19)

          On RI
          java version "1.5.0_19"
          Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02)
          Java HotSpot(TM) Client VM (build 1.5.0_19-b02, mixed mode)

          gives
          3.7314645675925406E19

          On Harmony
          Apache Harmony Launcher : (c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable.
          java version "1.5.0"
          Apache Harmony (1.5.0)
          DRLVM (11.2.0)
          pre-alpha : not complete or compatible
          svn = r808406, (Aug 27 2009), Windows/ia32/msvc 1310, release build
          http://harmony.apache.org

          gives
          9.223372036854776E18

          Show
          Tim Ellison added a comment - Math.floor(3.7314645675925406E19) On RI java version "1.5.0_19" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02) Java HotSpot(TM) Client VM (build 1.5.0_19-b02, mixed mode) gives 3.7314645675925406E19 On Harmony Apache Harmony Launcher : (c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable. java version "1.5.0" Apache Harmony (1.5.0) DRLVM (11.2.0) pre-alpha : not complete or compatible svn = r808406, (Aug 27 2009), Windows/ia32/msvc 1310, release build http://harmony.apache.org gives 9.223372036854776E18

            People

            • Assignee:
              Tim Ellison
              Reporter:
              Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development