-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
18
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
| Welcome to JShell -- Version 18
| For an introduction type: /help intro
jshell> BigInteger b = BigInteger.valueOf(Long.MAX_VALUE);
b ==> 9223372036854775807
jshell> b.sqrt();
$2 ==> 3037000499
jshell> 3037000499L*3037000499L
$3 ==> 9223372030926249001
jshell> 9223372036854775807L-9223372030926249001L
$4 ==> 5928526806
jshell> BigInteger c = b.sqrt();
c ==> 3037000499
jshell> c.pow(2);
$6 ==> 9223372030926249001
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
As with smaller integers:
jshell> BigInteger b = BigInteger.valueOf(16);
b ==> 16
jshell> b.sqrt();
$9 ==> 4
jshell> 4*4
$10 ==> 16
jshell> BigInteger c = b.sqrt();
c ==> 4
jshell> c.pow(2);
$12 ==> 16
| Welcome to JShell -- Version 18
| For an introduction type: /help intro
jshell> BigInteger b = BigInteger.valueOf(Long.MAX_VALUE);
b ==> 9223372036854775807
jshell> b.sqrt();
$2 ==> 3037000499
jshell> 3037000499L*3037000499L
$3 ==> 9223372030926249001
jshell> 9223372036854775807L-9223372030926249001L
$4 ==> 5928526806
jshell> BigInteger c = b.sqrt();
c ==> 3037000499
jshell> c.pow(2);
$6 ==> 9223372030926249001
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
As with smaller integers:
jshell> BigInteger b = BigInteger.valueOf(16);
b ==> 16
jshell> b.sqrt();
$9 ==> 4
jshell> 4*4
$10 ==> 16
jshell> BigInteger c = b.sqrt();
c ==> 4
jshell> c.pow(2);
$12 ==> 16