anguslai
asked on
Best way to convert Hex String to int?
Best way to convert Hex String to int?
eg. "FF" -> 255
P.S. Must work for Java 1.0
eg. "FF" -> 255
P.S. Must work for Java 1.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
thanks!
But it's like this:
value=(value*16)
But it's like this:
value=(value*16)
here is the best way to do it
String hex = ffabcc;
int value = Integer.parsInt(hex,16);
Thanks and Regards
Y. Kamesh Rao
String hex = ffabcc;
int value = Integer.parsInt(hex,16);
Thanks and Regards
Y. Kamesh Rao
if (hexString.charAt(0) == '-') value = Integer.decode("-0x" + hexString.substring(1));
else value = Integer.decode(hexString);
you will have to put this in a try catch block to catch number format exceptions....