I couldn't find it anywhere on the Internet, also this fact is not described in our FAQ.
parseByte(String s, int radix)
^^^
don't work when the result will be negative, it would throw java.lang.NumberFormatException.
Not dependant on lengh of String, radix, or inclusions of letters A...F.
For example, the following expression don't work:
Byte.parseByte("9A", 16);
The workaround is to use "(byte) Integer.parseInt(args)" with the same arguments.
I've tried this on the TC65i-X, but I'm sure this would be related to all the older chips also.
What do you think?
Can you check on your chip?
Do you have some other internal java methods that simply don't work?
Full list of trials, source code in attach:
Integer.parseInt("99")=99
Integer.parseInt("99", 10)=99
Integer.parseInt("99", 16)=153
Integer.parseInt("9A")=FAIL --- OK
Integer.parseInt("9A", 10)=FAIL --- OK
Integer.parseInt("9A", 16)=154
Byte.parseByte("99")=99
Byte.parseByte("99", 10)=99
This should produce -56
Byte.parseByte("200")=java.lang.NumberFormatException
- java.lang.Byte.parseByte(), bci=22
- java.lang.Byte.parseByte(), bci=3
- parsebytetest.IMlet.startApp(), bci=415
- javax.microedition.midlet.Main.run(), bci=3
This should produce -56
Byte.parseByte("200", 10)=java.lang.NumberFormatException
- java.lang.Byte.parseByte(), bci=22
- parsebytetest.IMlet.startApp(), bci=464
- javax.microedition.midlet.Main.run(), bci=3
This should produce -103
Byte.parseByte("99", 16)=java.lang.NumberFormatException
- java.lang.Byte.parseByte(), bci=22
- parsebytetest.IMlet.startApp(), bci=513
- javax.microedition.midlet.Main.run(), bci=3
Byte.parseByte("9A")=FAIL --- OK
Byte.parseByte("9A", 10)=FAIL --- OK
This should produce -102
Byte.parseByte("9A", 16)=java.lang.NumberFormatException
- java.lang.Byte.parseByte(), bci=22
- parsebytetest.IMlet.startApp(), bci=666
- javax.microedition.midlet.Main.run(), bci=3
Byte.parseByte("1A", 16)=26
Byte.parseByte("A", 16)=10
Byte.parseByte("0A", 16)=10
Integer.toHexString(26)=1a