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

Want Math.cbrt() function for cube root

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.3.0, 1.4.0
    • core-libs
    • tiger
    • generic, x86
    • generic, linux



      Name: sl110371 Date: 06/21/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


      It would be nice to have a Math.cbrt() function (cube root of a real number),
      for those of us involved in numerical/graphics programming.

      Looking at the JDK source code (publically available), there is a cbrt() native
      method defined in the library but it is unused. The Math class would need to
      be altered to call this method, similar to the way it invokes sqrt().

      Math.pow(x, 1/3.0) can be used to compute a cube root, but is much less
      efficient than a true cube root function. Also, special care must be taken for
      negative values of x. (See work-around).
      (Review ID: 105412)
      ======================================================================

      Name: rmT116609 Date: 02/19/2002


      DESCRIPTION OF THE PROBLEM :

      It would be nice to have a cubic root method in java.lang.Math, for example :

      public static double cbrt (double x)

      This mathematical function is defined for all real values regardless of their sign, but computing it with Math.pow cannot be done directly for non positive values. We have to end up with this kind of code :

      if (x >= 0)
        c = Math.pow (x, 1.0 / 3.0);
      else
        c = -Math.pow (-x, 1.0 / 3.0);

      (Review ID: 139858)
      ======================================================================

            darcy Joe Darcy
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: