Skip to content

Homework exercises after CS Fun class on Binary and Memory

Notifications You must be signed in to change notification settings

SoCodeDo/binary-and-decimal

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binary and Decimal

Author a method based on the binary to decimal algorithm you devised in class.

Exercises

Write a method named binary_to_decimal that receives as input parameter an array of size 8. The array is randomly filled with 0’s and 1’s. Assuming that the array represents an eight bit binary number with the most significant bit at index 0 and the least significant bit at index 7, calculate the decimal value for this binary number using the algorithm you devised in class. Return the decimal value.

Note: Do not use Ruby functions. You may use .length method on the array and retrieve values at a particular index in the array. Author using the algorithm you devised in class.

You may however write your own versions of these methods

Due Date This assignment is due Tuesday Sept 15th 7pm

You can test your program by running rake from the command line and it will run your method against a set of automated tests.

Optional

Add a decimal_to_binary method which converts a decimal number received as a parameter into an array of binary digits. Then write 3 tests for the method.

About

Homework exercises after CS Fun class on Binary and Memory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 80.9%
  • Dockerfile 18.4%
  • Shell 0.7%