JavaScript Program to Converter a Binary to Decimal
You are Here:
Converter a Number from Binary to Decimal
In the following example, we will convert a Binary number (1000001) to a Decimal number (65).
Tips: It is recommended to use our online Binary to Decimal converter for better understanding.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<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>
</body>
</html>
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.