You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/js/Math/Convert a binary number to ...

6 lines
203 B
JavaScript

function bin_to_dec(bstr) {
return parseInt((bstr + '')
.replace(/[^01]/gi, ''), 2);
}
console.log(bin_to_dec('110011'));
console.log(bin_to_dec('100'));