# Differences

This shows you the differences between two versions of the page.

 binary_to_decimal [2013/03/17 21:01]will created binary_to_decimal [2015/02/02 08:28] (current) 2013/04/29 09:45 will 2013/03/17 21:01 will created Next revision Previous revision 2013/04/29 09:45 will 2013/03/17 21:01 will created Line 1: Line 1: ====== Binary to decimal ====== ====== Binary to decimal ====== - A simple algorithm to convert a binary string to a decimal number in $O(n)$ time. For each character in the string the result is multiplied by $2$ and if the character is a '​1'​ then $1$ is added to the result. + A simple algorithm to convert a binary string to a decimal number in $O(n)$ time. For each character in the string the result is multiplied by $2$ and if the character is a '​1'​ then $1$ is added to the result. If a non '​0'​ or '​1'​ character is seen the conversion stops. + + In real-world Javascript use ''​parseInt("​100101",​ 2)''​. [algorithm binary_to_decimal] [algorithm binary_to_decimal]