For this project, write three separate codes:
1. Convert from decimal to binary.
2. Convert from binary to decimal.
3. Convert from decimal to IEEE-754 format.
Be sure to take into consideration whole numbers, floating-point numbers, and repeating patterns.
Write a code that will convert from IEEE-754 floating-point representation to decimal.
Hint: the built-in commands str2num and num2str may prove useful for certain parts of your code.
Copy your code, command lines, and answers for each case into a Word document.
function [Ibase2]= Convert10to2(Ibase10,n)
% Convert the integral part by successive divisions by 2
Ibase2=[];
if (Ibase10~=0)
while (Ibase10>0)
q=fix(Ibase10/2);
r=Ibase10-2*q;
Ibase2=[r Ibase2];
Ibase10=q;
end
else
Ibase2=0;
end
o = length(Ibase2);
% append redundant zeros
Ibase2 = [zeros(1,n-o) Ibase2];