Java - Recursion Program - Convert a base 10 number to any Base

后端 未结 5 577
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 07:30

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

5条回答
  •  死守一世寂寞
    2021-02-06 07:46

    A quick way to do it in Java is this:

    Integer.toString(int i,int radix);
    

    For example,

    Integer.toString(255,2)
    

    would return "11111111". I'm not sure if you are just looking for a quick solution or do you actually want to implement the conversion method yourself. This would be a quick solution. Refer to this post: What is the method in the API for converting between bases?

提交回复
热议问题