二进制转十进制

<pre name="code" class="java">private static void BinToDec(String str) {
	int p=0,m=0;
	for(int i=str.length()-1;i>=0;i--){
		char c = str.charAt(i);
		int a = Integer.parseInt(""+c);
		p=p+(int)(a*Math.pow(2, m));
		m++;
	}
	System.out.println(p);
}
    原文作者:进制转换
    原文地址: https://blog.csdn.net/xucongxiang/article/details/45080199
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞