how to work with other base numbers in java?

前端 未结 5 1875
广开言路
广开言路 2021-01-05 11:13

Guys if the int c=10001; which is a binary value.If i want to process it like multiplying it by 10 how to do that?

5条回答
  •  悲&欢浪女
    2021-01-05 11:58

    If I understand you correctly you want to do this: Integer.parseInt("10001", 2), which will give you 17.
    Integer.toString also accepts radix as second argument.

    Doc: Integer.parseInt(String s, int radix)

提交回复
热议问题