I am trying to convert a base 10 number to any base by using conversion. Right now this is the code I have came up with. I have a sad feeling this may be completely wrong. The
If you are just trying to convert bases (like to base 2), try the following code:
Integer.parseInt(Integer.toString(numberToConvert,base))
For specifically base 2:
Integer.parseInt(Integer.toBinaryString(numberToConvert))
Integer contains other methods such as toHexString that can be used. These assume that numberToConvert
is in base 10.