I am currently dealing with numbers with different bases. I am using the function Long.parseLong to convert a number from base int to its decimal value:
Long.parseLong(“A”, 16) to convert A which is a hexadecimal to its decimal value 10. I then use Long.toString(10, 16) to convert it back to A.
The problem now is that one of the entries in the problem set is “AAAAAAAAAAAAAAAAAAA” and when I use the Long.parseLong(); function, it returns an error because the size of the conversion can’t fit to a Long. I tried to use Float, but I’m afraid that there is no Float.parseFloat(String, int) with the int as its radix.
Is there an alternative which I can use?
BigInteger also doesn’t have any parse function with the radix.
Any help will be much appreciated.
BigIntegerhas a constructor, which does radix conversion for you:If you wish to convert back to hexadecimal, you can use
toString: