Okay.
I've worked out a script that converts binary to decimal, but I was, originally looking for the opposite effect. So now, I have a binary to decimal code, but I need a decimal to binary code.
Here it is:
Code:<html> <head> <script type="text/javascript"> function convert(string) { var extra = 8 - string.value.length for (i=0;i<=extra;i++) { if (string.value.length<8) {string.value=0+string.value} } var num var unum=128*2 var add var pos var binary for (i=1;i<=string.value.length;i++) { unum=unum/2 add=unum if (string.value.charAt(i-1)==0) {continue} binary+=add+"+" } alert(eval(binary.substring(9,binary.length-1))) } </script> </head> <body> <input id="code" value="00000010" maxlength="8"> <br><input type="button" value="Convert" onclick="convert(code)"> </body> </html>



Reply With Quote

Bookmarks