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

(porting) Jlong conversions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.0
    • hotspot
    • sparc
    • solaris_2.5.1

      Jlong conversions
      -----------------
      Casting a jlong to a jlong is unnecessary and does not work if a jlong is a
      structure.

      src\share\native\java\lang\double.c

      /*
       * Find the double float corresponding to a given bit pattern
       */
      JNIEXPORT jdouble JNICALL
      Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass unused, jlong v)
      {
          union {
              jlong l;
              double d;
          } u;
          jlong_to_jdouble_bits(&v);
      #if defined IBM_ALL /*ibm*/
          u.l = v;
      #else /*ibm*/
          u.l = (jlong)v;
      #endif /*ibm*/
          return (jdouble)u.d;
      }

      /*
       * Find the bit pattern corresponding to a given double float
       */
      JNIEXPORT jlong JNICALL
      Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass unused, jdouble v)
      {
          union {
              jlong l;
              double d;
          } u;
          if (JVM_IsNan((double)v)) {
              u.l = jint_to_jlong(0x7ff80000);
              return jlong_shl(u.l, 32);
          }
          jdouble_to_jlong_bits(&v);
          u.d = (double)v;
      #if defined IBM_ALL /*ibm*/
          return u.l;
      #else /*ibm*/
          return (jlong)u.l;
      #endif /*ibm*/
      }

            tturnidgsunw Todd Turnidge (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: