User talk:Samitha herath

python code to convert 32 bit double float into decimal

repete='y' while repete=='y' or repete=='Y': error=0; binnum=input('enter the 32 bit number:');

for i in range(0,31,1): if binnum[i]!='0' and binnum[i]!='1': error=1; if len(binnum)!=32 or error==1: print('give a correct 32-bit binary number'); else:

signb=int(binnum[0]); expb=binnum[1:9]; restb=binnum[9:];

ex=0;

for k in range(0,8,1): ex=ex+int(expb[k])*(2**(7-k)); expd=int(ex-127);

intpart="1"+restb[0:expd]; decpart=restb[expd:];

integerval=0; decvalue=0; for m in range(0,len(intpart)-1,1): integerval=integerval+(int(intpart[m])*(2**(len(intpart)-m-1)));

for p in range(0,len(decpart)-1,1): decvalue=decvalue+(int(decpart[p]))*(2**((-1)*(p+1))) out1=integerval+decvalue;