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

java.lang.Bignum.sqrt() hangs or works wrong

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

      1. This method should throw some exception if the value is negative but it doesn't.
      2. Specification doesn't describe its behaviour in case of negative values

      3. It works wrong if the value is positive.

      4. Specification does not say about the scale of the result.
       
      === Here is the test for negative value ===
      import java.lang.Bignum;
      class java_lang_Bignum_sqrt {
        public static void main(String args[]) {
          Bignum b1=new Bignum("-1");
          System.out.println(b1.sqrt()); // will not return
        }
      }
      === Here is the test for positive value ===
      import java.lang.Bignum;
      class java_lang_Bignum_sqrt {
        public static void main(String args[]) {
          Bignum b1=new Bignum("1");
          System.out.println(b1.sqrt()); //Should print "1" but prints "1.2"
        }
      }
      ==== Here is the output of the test ===
      1.2

            mhapnersunw Mark Hapner (Inactive)
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: