Sei sulla pagina 1di 1

clc

clear
m=0;s=0;n=0;k=0;
b=input(' enter the binary number : ');
while ( b~=0 && n<20 )
a=b/10;
b=floor(a);
e=((a-b)*10)+0.5;
c=floor(e);
if (c==0 || c==1 )
z=c*(2^m);
s=s+z;
n=n+1;
else
k=k+1;
end
m=m+1;
end
if ( k==0 ) && ( n<=16 )
display ( s )
else if ( k+n ) >16
display(' so long no. ');
else if ( k~=0 )
display ( ' the no. is not binary ')
end
end
end

Potrebbero piacerti anche