Skip to content

Conversation

@scottzec
Copy link

Binary and Decimal

Congratulations! You're submitting your assignment.

Copy link
Collaborator

@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 the learning goals here. Well done.

Comment on lines +13 to +35

# Generates random array to pass as argument in binary_to_decimal method
binary_numbers = Array.new(8) {rand (0..1)}

binary_to_decimal(binary_numbers)


# Test Arrays

array = [1, 1, 1] #7

arr2 = [1, 0, 0, 1] #9

arr3 = [1, 0, 1, 1] #11

arr4 = [0, 1, 1, 1] #7


# puts binary_to_decimal(array)

# puts binary_to_decimal(arr2)

# puts binary_to_decimal(arr3) + binary_to_decimal(arr4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Generates random array to pass as argument in binary_to_decimal method
binary_numbers = Array.new(8) {rand (0..1)}
binary_to_decimal(binary_numbers)
# Test Arrays
array = [1, 1, 1] #7
arr2 = [1, 0, 0, 1] #9
arr3 = [1, 0, 1, 1] #11
arr4 = [0, 1, 1, 1] #7
# puts binary_to_decimal(array)
# puts binary_to_decimal(arr2)
# puts binary_to_decimal(arr3) + binary_to_decimal(arr4)

Comment on lines +2 to 4
# Calculate and return the decimal value for this binary number using the algorithm you devised in class.

def binary_to_decimal(binary_array)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Well done

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