dual:

dezimal:

 

dezimal:

dual:

 

Info Zahlsysteme

 

<HTML>

<HEAD>

<TITLE>Zahlsysteme</TITLE>

<script language="JavaScript">

function berechne1(x) {

n=x.length;

sum=0;

for (i=1; i<=n; i++) {

y=x[n-i];

sum=sum+y*Math.pow(2,i-1);

}

form1.dezimal.value=sum;

}

function berechne2(x) {

rest="";

while (x>0) {rest=rest+x%2;x = Math.floor(x/2);}

n=rest.length;

ergebnis="";

for (i=0; i<n; i++) ergebnis=ergebnis+rest[n-i-1];

form2.dual.value=ergebnis;

}

</script>

</HEAD>

<BODY>

<FORM name=form1>

<P>dual: <INPUT TYPE=text NAME=dual VALUE="" SIZE=30>

<P><INPUT TYPE=button VALUE="rechne" onclick="berechne1(form1.dual.value)">

<P>dezimal: <INPUT TYPE=text NAME=dezimal VALUE="" SIZE=30>

</FORM>

<P><FORM name=form2>

<P>dezimal: <INPUT TYPE=text NAME=dezimal VALUE="" SIZE=30>

<P><INPUT TYPE=button VALUE="rechne" onclick="berechne2(form2.dezimal.value)">

<P>dual: <INPUT TYPE=text NAME=dual VALUE="" SIZE=30>

</FORM>

</BODY>

</HTML>


Jürgen Giesen