Skip to content

Instantly share code, notes, and snippets.

@mindplace
Created April 4, 2016 03:22
Show Gist options
  • Save mindplace/85e7052a78b70878ec103be9b24b6e2b to your computer and use it in GitHub Desktop.
Save mindplace/85e7052a78b70878ec103be9b24b6e2b to your computer and use it in GitHub Desktop.
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