The problem is that 0x9774d56d682e549c is a positive value that's too
large to fit in a 64 bit long. If the intent is that the high bit of
the first digit indicates sign, then you'll need to mask off the high
bit and add a leading minus sign when the high bit is on. E.g.
Long.decode("-0x1774d56d682e549c")

- Dave

On Aug 10, 3:29 pm, RLScott <[email protected]> wrote:
> I am trying to convert a string of 16 hex digits to a 64-bit Long, but
> there is a run-time exception for negative values:
>
>     Long a = Long.decode("0x3774d56d682e549c"); //..works just fine
>
>     Long a = Long.decode("0x9774d56d682e549c"); //..crashes with a run-
> time exception
>
> Apparently you can't decode a hex string that is negative as a 64-bit
> Long.  Why?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to