Skip to content

Commit bd77db3

Browse files
aalesvdschultzca
authored andcommitted
Added ability to parse negative hex numbers
1 parent 69535ec commit bd77db3

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/main/java/com/romraider/util/HexUtil.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,7 @@ public static void hexToBytes(String s, byte[] out, int off) throws NumberFormat
159159
* @return integer value
160160
*/
161161
public static int hexToInt(String input) {
162-
if (input.length() > 2 && input.substring(0, 2).equalsIgnoreCase("0x")) {
163-
return Integer.parseInt(input.substring(2), 16);
164-
} else {
165-
return Integer.parseInt(input, 16);
166-
}
162+
return Integer.parseInt(input.replace("0x",""), 16);
167163
}
168164

169165
/**

0 commit comments

Comments
 (0)