HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>Binary to Decimal Converter</h1> <script> var num = 1000001; var arr = []; var i = -1; var j; var total = 0; while(num != 0) { i++; arr[i] =num % 10; // console.log(arr[i]); num = Math.floor(num / 10); } for(j=i; j>=0; j--) total += (arr[j] * Math.pow(2, j)); document.write(total); </script> <p><strong>Note</strong>: In this example, binary number (1000001) is converted into decimal number (65).</p> </body> </html>
OUTPUT
×

Save as Private