二进制转十进制

来源:互联网 发布:mac安装hexo 编辑:程序博客网 时间:2024/05/21 06:43
<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);}


                                             
0 0
原创粉丝点击