<分区>
主要内容:
public class Main{
public static void main(String[] args){
System.out.println(Convert.BtoI("101101010101"));
System.out.println(Convert.BtoI("1011110"));
}
}
子:
public class Convert{
public static int BtoI(String value){
int no = 0;
for(int i=value.length()-1;i>=0;i--){
if(value.charAt(i)=='1')
no += (???) ;
++;
}
return no;
}
}
如何在不使用 maths.pow
的情况下将二进制字符串转换为整数? ,只使用 + - * 和/,我应该为它实现另一个 for 循环吗 int j = 1;i <= example; i*=2){
?。我很困惑,想在不使用 maths.pow
的情况下学习或任何类似的代码。