I am in trouble.
I need to convert a signed 16-bit Hexadecimal no to short.
Say I have a string s = "f2f7"
Which is a negative number and lies in the range -32768 to 32767 so is the range of type short.
But when I do
short num ;
num = Short.parseShort(s, 16) ;
it throws an exception complaining about out of range value for short.
Actually it treats it as Integer and convert f2f7 to 62199 and then tries to assign it to num which is short.
I have views the source of parseShort and it calls Integer.parseInteger(s, i) inside it.
How can I get actual signed value of "f1f7" and assign it to my short (num) ??
it works fine for values in the range "0000" to "7fff".