Skip to content

Instantly share code, notes, and snippets.

@mindplace
Created April 4, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindplace/163fe26593fd000990dc95b860d02b31 to your computer and use it in GitHub Desktop.
Save mindplace/163fe26593fd000990dc95b860d02b31 to your computer and use it in GitHub Desktop.
function BinaryConverter(binNum) {
var numArray = binNum.toString().split("").reverse();
var number = 0;
for (var i=0; i < numArray.length; i++) {
var num = parseInt(numArray[i]);
var location = Math.pow(2, i);
number += num * location;
}
return number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment