Skip to content

Instantly share code, notes, and snippets.

@spaced-out-factory
Created October 24, 2016 22:26
Show Gist options
  • Select an option

  • Save spaced-out-factory/afa0f3a50737c79e2a11fa4cd84c06fc to your computer and use it in GitHub Desktop.

Select an option

Save spaced-out-factory/afa0f3a50737c79e2a11fa4cd84c06fc to your computer and use it in GitHub Desktop.
Binary converter
binary = "1111"
position = 0
values = []
sum = 0
for i = 0; i < binary.length; i++
position++
if number(binary[i])
if position > 1
values.push(position * 2)
else
values.push(1)
endif
endif
endfor
for i = 0; i < values.count(); i++
sum += values[i]
endfor
print(sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment