Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

convert hex to long

Thread view: 
Jeff - 20 Dec 2005 20:39 GMT
Hey

midp 2.0
J2ME Wireless Toolkit 2.2
JDK 5

Long id;
String arg1 = "0b";  //arg1 can also have values like "01", "0a" etc
id = Long.parseLong(arg1);

This converting isn't working with "0b" or "0a"... but I've read in the
documentation of jdk5 that this parseLong is overloaded:
public static long parseLong(String s, int radix), and I guess this is the
correct method to use, but I'm not sure what the second parameter (radix) of
this method is?

Jeff
Gordon Beaton - 20 Dec 2005 21:06 GMT
> Long id;
> String arg1 = "0b";  //arg1 can also have values like "01", "0a" etc
[quoted text clipped - 5 lines]
> correct method to use, but I'm not sure what the second parameter (radix) of
> this method is?

"Radix" is another word for "base".

If your string contains a base 16 number, specify 16.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Oliver Wong - 21 Dec 2005 21:36 GMT
>> Long id;
>> String arg1 = "0b";  //arg1 can also have values like "01", "0a" etc
[quoted text clipped - 11 lines]
>
> If your string contains a base 16 number, specify 16.

   And in case that wasn't explicit enough, hexadecimal is base 16. Octal
is base 8. Binary is base 2. Decimal is base 10. Etc.

   So for the OP's problem, yes, you want to use 16.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.