Skip to content

Sockets- Kate N#41

Open
KateAnnNichols wants to merge 1 commit intoAda-C11:masterfrom
KateAnnNichols:master
Open

Sockets- Kate N#41
KateAnnNichols wants to merge 1 commit intoAda-C11:masterfrom
KateAnnNichols:master

Conversation

@KateAnnNichols
Copy link
Copy Markdown

Binary and Decimal

Congratulations! You're submitting your assignment.

Comment thread lib/binary_to_decimal.rb
def binary_to_decimal(binary_array)
raise NotImplementedError
decimal = 0
8.times do |i|
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job with the do ... loop. Can you think of a way to generalize the algorithm so that it works for n bits?

Comment thread lib/binary_to_decimal.rb
raise NotImplementedError
decimal = 0
8.times do |i|
decimal += binary_array[i] * 2 ** (7 - i)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job with using the math operator **. Can you think of a faster way to perform this without having to use the ** operation? Your code currently requires recalculating 2 to the power of n (number of bits) at every iteration.

@shrutivanw
Copy link
Copy Markdown
Collaborator

Nice work!

Think about the comments and questions that your code review buddy shared with you, and discuss them further with your buddy.

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.

3 participants