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

JDK Bug in Double Operations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.1.4
    • 1.1.4
    • vm-legacy
    • None
    • jit
    • 1.1.4
    • sparc
    • solaris_2.5.1
    • Not verified

      amateur % pwd
      /home/liang/bug/jdk114
      amateur % uname -a
      SunOS amateur 5.5.1 Generic_103640-08 sun4u sparc SUNW,Ultra-1
      amateur % java -version
      java version "1.1.4"
      amateur % javac bug.java
      amateur % java bug
       Error: result = 1536.834181305364
             must be = 2.6880135699674716E14
      amateur % cat bug.java
      public class bug {

        private static double fun (double x)
        {
          double t1 = Math.sqrt(x);
          return t1*Math.exp(x);
        }

      /***************************************************************/

        private static double fun_correct (double x)
        {
          return Math.sqrt(x)*Math.exp(x);
        }

      /***************************************************************/

        public static void main(String[] argv) {
          double x = 31.5;
          if (fun(x) != fun_correct(x)) {
             System.out.println(" Error: result = "+fun(x));
             System.out.println(" must be = "+fun_correct(x));
          }
          else
           System.out.println(" TEST PASSED");
        }
      }
      amateur %

            dmcox David Cox (Inactive)
            liahe Liang He (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: