# Lab 5 - Engineering 7 Introduction to Programming for...

This preview shows pages 1–2. Sign up to view the full content.

Engineering 7: Prof. Alexandre Bayen Introduction to Programming for Engineers Spring 2011 Lab 5: Complexity and Numerical Precision Date Assigned: 5:00pm, Friday – Mar 4. Date Due: 5:00pm, Friday – Mar 11. Problem 1: Do Problem 8.1 in the Reader Test Cases: >> d = myBin2Dec([1 1 1]) d = 7 >> d = myBin2Dec([0 0 0 0 0]) d = 0 >> d = myBin2Dec([1 0 1 0 1 0 1]) d = 85 >> d = myBin2Dec(ones(1,25)) d = 33554431 Problem 2: Do Problem 8.2 in the Reader. Clarification : The output must be a row vector and the leading term must be a 1 unless the decimal input value is 0. Test Cases: >> b = myDec2Bin(0) b = 0 >> b = myDec2Bin(23) b = 1 0 1 1 1 >> b = myDec2Bin(2097) b = 1 0 0 0 0 0 1 1 0 0 0 1 Problem 3: Do Problem 8.4 in the Reader. Clarification : Write a function with header [b] = myBinAdder(b1,b2) where b1 , b2 , and b are binary numbers represented as in Problem 1. The output variable should be computed as b = b1 + b2 . Do not use your functions from Problem 1 and 2 to write this function (i.e., do not convert b1 and b2 to decimal, add them, then convert the result back to binary). This function should be able to be able to accept inputs

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern