Matlab binary to decimal conversion?
-
using the pseudo code below, what would the matlab code be for Problem 1. Implement in matlab the following functions: 1. function DecimalToBinary (d) 2. function BinaryToDecimal (b) 3. function BinarySum (a1,a2) 4. function BinaryProd (f1,f2) The first function accepts a real number d and converts it into a row vector of 64 binary elements, each either 0 or 1. These 64 binary elements must respect the finite precision binary representation seen in class for real numbers (one sign bit, 11 exponent bits, 52 mantissa bits). The second function does the opposite: given a vector b of 64 binary elements, it returns the corresponding (finite precision) real number. The last two functions return the binary representation (i.e., a binary vector) of the sum (resp. the product) of the two arguments passed, both expressed as vectors of 64 binary elements. Test these functions by running 20 times the following test (turn in the code used for this test): 1. Generate two random numbers n1 and n2, both between −10^8and 10^8. 2. Translate them into two vectors v1 and v2 using DecimalToBinary. 3. Compute their sum and their products using BinarySum and BinaryProd; each will output binary vectors. Call them bsum and bprod. 4. Convert bsum and bprod to decimal using BinaryToDecimal, and check if they are indeed the sum and product of n1 and n2.
-
Answer:
Walt P at Yahoo! Answers Visit the source
Related Q & A:
- How to limit the number of decimal digits in ARCGIS to have the exported file in CAD with the same format?Best solution by Geographic Information Systems
- How can I track third party conversion?Best solution by Quora
- Is it true that the Chick-fil-A franchise helps fund and supports "conversion/reparative" therapy on LGBT's?Best solution by answers.yahoo.com
- Can you do a conversion course for law if you do a degree in?Best solution by Yahoo! Answers
- What is a good adwords conversion rate?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.