Skip to content

Branches - Macaria#46

Open
mdove92 wants to merge 1 commit intoAda-C12:masterfrom
mdove92:master
Open

Branches - Macaria#46
mdove92 wants to merge 1 commit intoAda-C12:masterfrom
mdove92:master

Conversation

@mdove92
Copy link

@mdove92 mdove92 commented Sep 3, 2019

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.

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

index = binary_array.length - 1
result = 0
while index >= 0
result += binary_array[index] * (2 ** (7 - index))

Choose a reason for hiding this comment

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

I suggest making 7 a constant or using the binary_array.length -1 just to make the code a bit more flexible. Using specific numbers like 7 in code are sometimes called "magic 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