二进制如何转为十进制(浮点数 c++)
发布网友
发布时间:2022-05-02 02:12
我来回答
共5个回答
热心网友
时间:2022-06-26 19:20
"10 >> 2"
,"十进制转为二进制"
,"十进制数值∶",0,,,,"#NUM!","二进制数值∶",0
,2,0,"…",0,1,"#NUM!"
,2,0,"…",0,10,"#NUM!"
,2,0,"…",0,100,"#NUM!"
,2,0,"…",0,1000,"#NUM!"
,2,0,"…",0,10000,"#NUM!"
,2,0,"…",0,100000,"#NUM!"
,2,0,"…",0,1000000,"#NUM!"
,2,0,"…",0,10000000,"#NUM!"
,2,0,"…",0,100000000,"#NUM!"
,2,0,"…",0,1000000000,"#NUM!"
"2 >> 10"
,"二进制转为十进制"
,,,,"#NUM!",,"於十进制的值"
,"二进制数值∶",0,,"#NUM!",10,0,"x",2,0,"=",0
,,,,"#NUM!",100,0,"x",2,1,"=",0
,"十进制数值∶",0,,"#NUM!",1000,0,"x",2,2,"=",0
,,,,"#NUM!",10000,0,"x",2,3,"=",0
,,,,"#NUM!",100000,0,"x",2,4,"=",0
,,,,"#NUM!",1000000,0,"x",2,5,"=",0
,,,,"#NUM!",10000000,0,"x",2,6,"=",64
,,,,"#NUM!",100000000,0,"x",2,7,"=",128
,,,,"#NUM!",1000000000,0,"x",2,8,"=",256
,,,,"#NUM!",10000000000,0,"x",2,9,"=",512
,,,,,100000000000,"总和= ",,,,,0
"10>>2(digit)"
,"十进制小数转为二进制小数"
,"十进制小数∶",,,"小数部份乘二","整数部份","小数部分"
,,,,0,0,0,0.1
,"二进制小数∶",0,,0,0,0,0.01
,,,,0,0,0,0.001
,,,,0,0,0,0.0001
,,,,0,0,0,"1E-05"
,,,,0,0,0,"1E-06"
,,,,0,0,0,"1E-07"
,,,,0,0,0,"1E-08"
,,,,0,0,0,"1E-09"
,,,,0,0,0,"1E-10"
,,,,0,0,0,"1E-11"
,,,,0,0,0,"1E-12"
,,,,0,0,0,"1E-13"
,,,,0,0,0,"1E-14"
,,,,0,0,0,"1E-15"
,,,,0,0,0,"1E-16"
,,,,0,0,0,"1E-17"
,,,,0,0,0,"1E-18"
,,,,0,0,0,"1E-19"
,,,,0,0,0,"1E-20"
,,,,0,0,0,"1E-21"
"2>>10(digit)"
,"二进制小数转为十进制小数"
,"二进制小数∶",,,,,"数位"
,,,0,10,,0,"x",2,-1,"=",0
,"十进制小数∶",0,0,100,,0,"x",2,-2,"=",0
,,,0,1000,,0,"x",2,-3,"=",0
,,,0,10000,,0,"x",2,-4,"=",0
,,,0,100000,,0,"x",2,-5,"=",0
,,,0,1000000,,0,"x",2,-6,"=",0
,,,0,10000000,,0,"x",2,-7,"=",0
,,,0,100000000,,0,"x",2,-8,"=",0
,,,0,1000000000,,0,"x",2,-9,"=",0
,,,0,10000000000,,0,"x",2,-10,"=",0
,,,,,,,,,"总和∶",,0
热心网友
时间:2022-06-26 19:20
楼上的 好像还是不能解决浮点数的问题啊
int i=0;
int j,k=0;
double value=0.0;
char d[100];
cout<<"请输入:\n";
cin>>d;
j=strlen(d);
for(i=(j-1);i>=0;i--)
{
if(d[k++]=='1')
value+=double(power(2,i));
};
cout<<"十进制是:"<<value<<endl;
这段可以解决二进制转为十进制 但是不能实现浮点数的运算 大家继续帮忙啊(我是楼主)
热心网友
时间:2022-06-26 19:21
楼上的,你用的是什么语言,我怎么看不明白啊。
用c语言编程:
include<stdio.h>
include<math.h>
main()
{struct stack{
int top;
int base;
int a[];};
a=(int *)malloc(100*sizeof(int);//动态分配空间
top=base=0;//建立一个空栈
int m;
long s=0;
int list[]={"在此输入你想转换的二进制数"};
m=strlen(list);
int b[m];
int *p=list;
if(*p!=\0)
{a[top]=*p;top++;p++;}
do{ for(i=0;;i++)
b[i]=a[--top];
}when(top==base);
for(i=0;i<m;i++)
s=s+pow(int (2*b[i]),int i);
printf("%ld",s);
}
热心网友
时间:2022-06-26 19:21
用8421算最简单,从二进制的后面开始算起,例如
100010010111,从后面4个为一组,二进制为1的数字对应,为0的数字不对应!!!
8 4 2 1
0 1 1 1
0+4+2+1=7
记住要从后向前算!!
热心网友
时间:2022-06-26 19:22
用计算机知识你可以啦