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
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