I am looking to create a java method that takes a 4-byte signed hex number and convert it into an int. However, when I test inputs such as "aaaaaaaa" or "ffffffff"
Integer.valueOf("aaaaaaaa", 16)
Integer.valueOf("ffffffff", 16)
which should give the values: -1431655766 and -1 respectively.
However, I am getting the following exception
Exception in thread "main" java.lang.NumberFormatException: For input string: "ffffffff"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
at java.lang.Integer.valueOf(Integer.java:740)
at ByteTest.main(ByteTest.java:8)
What can I do to fix this?