Wednesday, August 10, 2011

[android-developers] Re: Why does Long.decode fail?

I think it treats the hex value as positive as it can be preceeded by
a minus sign. From the docs:

" The string may be an optional minus sign "-" followed by a
hexadecimal ("0x..." or "#..."), octal ("0..."), or decimal ("...")
representation of a long."

I agree it is unclear.


On Aug 10, 8:29 pm, RLScott <fixthatpi...@yahoo.com> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate