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

Math.sin(double) result not within 1 ulp

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Tested on systems running:
      Windows 10 - "java 22.0.2 2024-07-16"
      Windows 10 - "java 21.0.2 2024-01-16 LTS"
      Ubuntu 20.04.6 LTS (GNU/Linux 5.4.43 x86_64) - "java 22.0.1 2024-04-16"

      A DESCRIPTION OF THE PROBLEM :
      The 32-bit float value "0xeff9be45" i.e. "Float.intBitsToFloat(0xeff9be45);" gives a result for Math.sin(0xeff9be45) which is off by a factor of 10^9.
      The Math.sin(double) function is stated as having "The computed result must be within 1 ulp of the exact result." - https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/Math.html#sin(double)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compute Math.sin((double) Float.intBitsToFloat(0xeff9be45));

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      double value within 1 ULP of "-0.999669740398802370445554517844591084269650501599989210353510184..."
      ACTUAL -
      0x3e2bbdd52a58eafb ~= 3.2295395964952422305120878709893891822524381041148444637656 x 10^-9

      ---------- BEGIN SOURCE ----------
      public class Test {
      public static void main(String[] args) {
      double value = (double) Float.intBitsToFloat(0xeff9be45);
      value = Math.sin(value);
      System.out.println(value);
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: