如何在java中使用其他基数? [英] how to work with other base numbers in java?
本文介绍了如何在java中使用其他基数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果int c = 10001,则为人;这是一个二进制值。如果我想处理它就像乘以10怎么做?
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?
推荐答案
如果我理解你的话你想要这样做: Integer.parseInt(10001, 2)
,它将为您提供17.
Integer.toString
也接受基数作为第二个参数。
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)
这篇关于如何在java中使用其他基数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文