Created
April 10, 2014 19:56
-
-
Save guilhermehn/10417176 to your computer and use it in GitHub Desktop.
Binary to Decimal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function binToDecimal (n) { | |
var i = s = 0, h | |
while (h = n[i]) { | |
s += (1 << n.length - ++i) * h | |
} | |
return s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment