Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4334484

Double and Float should have primitive comparator methods

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • beta
    • sparc
    • solaris_2.6

      Double has a compareTo method that describes a natural ordering for double
      values. But if I'm working with primitive values I can't use them without
      creating objects. If I'm writing my own sort method for a double array,
      for example, I will have to recreate the logic of compareTo in my method,
      since

      if (d1 < d2) ...

      doesn't do the right thing in many cases. I would like a compare method,
      as in

      /**
      * Compares the two double values, returning the equivalent of
      * new Double(d1).compareTo(new Double(d2))
      */
      public static int compare(double d1, double d2) { ... }

      And an equivalent one for Float.

            mmcclosksunw Michael Mccloskey (Inactive)
            karnoldsunw Kenneth Arnold (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: