I\'m trying to convert a number from an integer into an another integer which, if printed in hex, would look the same as the original integer.
For example:
C
public static int convert(int n) { return Integer.valueOf(String.valueOf(n), 16); } public static void main(String[] args) { System.out.println(convert(20)); // 32 System.out.println(convert(54)); // 84 }
That is, treat the original number as if it was in hexadecimal, and then convert to decimal.