Bug in Long.parseUnsignedLong
roger riggs
roger.riggs at oracle.com
Thu Dec 19 16:26:49 UTC 2013
Created JDK-8030814 <https://bugs.openjdk.java.net/browse/JDK-8030814>
to track this issue.
Roger
On 12/18/2013 6:52 PM, Louis Wasserman wrote:
> Derp. Here is the test case:
>
> import java.math.BigInteger;
>
> public class UnsignedLongBug {
> public static void main(String[] args) {
> try {
> String input = "1234567890abcdef1";
> System.out.println(Long.parseUnsignedLong(input, 16));
> BigInteger maxUnsignedLong =
> BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE);
> BigInteger inputValue = new BigInteger(input, 16);
> System.out.println(maxUnsignedLong.compareTo(inputValue));
> throw new AssertionError();
> } catch (NumberFormatException expected) {
> System.out.println("Correct");
> }
> }
> }
>
>
> On Wed, Dec 18, 2013 at 3:51 PM, Louis Wasserman <lowasser at google.com>wrote:
>
>> The Javadoc of Long.parseUnsignedLong specifies that it should throw a
>> NumberFormatException if "the value represented by the string is larger
>> than the largest unsigned long, 2^64-1."
>>
>> This does not appear to be happening:
>>
>> --
>> Louis Wasserman
>>
>
>
More information about the core-libs-dev
mailing list