Uploaded image for project: 'Commons Numbers'
  1. Commons Numbers
  2. NUMBERS-185

Precision.compareTo with ulps cannot be used for sorting

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.0
    • 1.1
    • core
    • None

    Description

      The Precision.compareTo class was fixed in NUMBERS-154 to allow correct handling of NaN values. This fixed was applied to the compareTo with a delta but not compareTo using a max ULP argument.

      This can be fixed by using Double.compare (as is done in compareTo(double, double, double):

          public static int compareTo(final double x, final double y, final int maxUlps) {
              if (equals(x, y, maxUlps)) {
                  return 0;
              } else if (x < y) {
                  return -1;
              } else if (x > y) {
                  return 1;
              }
              // NaN input.
              return Double.compare(x, y);
          } 

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aherbert Alex Herbert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: