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

Addition of varargs version of Math.min() and Math.max()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0, 6
    • core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      Please provide us with varargs version of Math.min() and Math.max(), now that we have the celebrated varargs feature in Tiger.

      It would even be neatly implemented (but not strictly necessary) if it takes the following approach:

      public <T extends WellOrderedNumber> T min(T ... nums) {
          T ret = nums[0];
          for(T num : nums)
              ret = min(ret, num);
          return ret;
      }

      which also utilises the auto-boxing / unboxing feature of the language as well.

      JUSTIFICATION :
      It is evidently useful to have varargs version of min() and max() compare to the existing binary comparison methods.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      long ans = Math.min(a, b, c, d, e, f);
      ACTUAL -
      long ans = Math.min(a, Math.min(b, Math.min(c, Math.min(d, Math.min(e, f)))));
      ###@###.### 2005-03-11 00:33:18 GMT

            darcy Joe Darcy
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: