Created
April 4, 2016 03:22
-
-
Save mindplace/85e7052a78b70878ec103be9b24b6e2b to your computer and use it in GitHub Desktop.
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
def from_binary(number) | |
number_array = number.to_s.chars.reverse | |
returning = 0 | |
number_array.each_with_index do |item, i| | |
location = 2 ** i | |
returning += (location * item.to_i) | |
end | |
returning | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment