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

Static Method longBitsToDouble(long l) from class Double returns wrong value.

XMLWordPrintable

    • 1.2
    • sparc
    • solaris_2.4
    • Not verified


      [Please see evaluation also]

      Static Method longBitsToDouble(long bits) from Class Double returns wrong values
      when bits is 0x7f80000000000000L and 0xff80000000000000L return should be Infinity and -Infinity. Run following code to reproduce problem

      ’ž†

      public class LongToDouble {

        public static void main(String[] argv) {

          double d;
          // Test For Infinity
          d = Double.longBitsToDouble(0x7f80000000000000L);
          if ( Double.isInfinite(d))
            System.out.println("Test Passed for Infinity: " + Double.toString(d));
          else
            System.out.println("Test Failed for Infinity: " + Double.toString(d));

          // Test For -Infinity
          d = Double.longBitsToDouble(0xff80000000000000L);
          if ( Double.isInfinite(d))
            System.out.println("Test Passed for Infinity: " + Double.toString(d));
          else
            System.out.println("Test Failed for Infinity: " + Double.toString(d));
        }
      }

            gbrachasunw Gilad Bracha (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: