Skip to content

Conversation

@NatalieTapias
Copy link

Binary and Decimal

Congratulations! You're submitting your assignment.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, you hit all the learning goals here! Well done.

until num == 0
modulo = (num % 2).to_s
num /= 2
binary_number = modulo+binary_number

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever use of string concatenation to reverse things.

def binary_to_decimal(binary_array)
raise NotImplementedError
decimal = 0
exponent = 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I suggest making 7 a constant or binary_array.length - 1 to avoid hardcoding in specific numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants