Question

In: Computer Science

Write a program that converts a given floating point binary number with a 24-bit normalized mantissa...

Write a program that converts a given floating point binary number with a 24-bit normalized mantissa and an 8-bit exponent to its decimal (i.e. base 10) equivalent. For the mantissa, use the representation that has a hidden bit, and for the exponent use a bias of 127 instead of a sign bit. Of course, you need to take care of negative numbers in the mantissa also. Use your program to answer the following questions: (a) Mantissa: 11110010 11000101 01101010, exponent: 01011000. What is the base-10 number? (b) What is the largest number (in base 10) the system can represent? (c) What is the smallest non-zero positive base-10 number the system can represent? (d) What is the smallest difference between two such numbers? Give your answer in base 10. (e) How many significant base-10 digits can we trust using such a representation?

Mention: Matlab

Solutions

Expert Solution

Solution for the above question is provided below. If any doubt please comment below.

a)

%Given inputs
expnt='01011000';
mant='111100101100010101101010';

% Signbit
signBit=str2num(mant(1));

%Find mantissa
manti=mant(2:24);

% compute exponent
exponent=0;
dj=length(expnt);
for di=1:length(expnt)
   exponent=str2num(expnt(di))*2^(dj-1)+exponent;
    dj=dj-1;
end

% Find bias
ex=-127+exponent;
decim=0;

%compute the value
for di=1:length(manti)
   decim=str2num(manti(di))*2^(-di)+decim;
end

format long

% Result
res=(-1)^signBit*(1+decim)*2^(ex)

Output:

b)

To find it make exponent as all 1's and also make mantissa all as 1 except first bit in the above program

%Given inputs

expnt= '11111111';

mant='011111111111111111111111';

Output:

c)

%Given inputs

expnt= '00000000';

mant= '000000000000000000000000' ;

Output:

d)

First run the program using below mantissa and exponent

expnt='00000000';
mant='011111111111111111111111';

Second run the program using below mantissa and exponent

expnt='00000000';
mant='011111111111111111111110';

Find the difference of both result

Output:

e)

Number of significant base-10 digits = 2-23


Related Solutions

The number –11.375 (decimal) represented as a 32-bit floating-point binary number according to the IEEE 754...
The number –11.375 (decimal) represented as a 32-bit floating-point binary number according to the IEEE 754 standard is
Find the 3-bit mantissa floating point representation of the following numbers, both by chopping and rounding,...
Find the 3-bit mantissa floating point representation of the following numbers, both by chopping and rounding, and then calculate the associated respective absolute error and relative error: (a) 11/16 (b) 2.75
Given the following 32-bit binary sequences representing single precision IEEE 754 floating point numbers: a =...
Given the following 32-bit binary sequences representing single precision IEEE 754 floating point numbers: a = 0100 0000 1101 1000 0000 0000 0000 0000 b = 1011 1110 1110 0000 0000 0000 0000 0000 Perform the following arithmetic and show the results in both normalized binary format and IEEE 754 single-precision format. Show your steps. a)     a + b b)     a × b
Assume that you have a 12-bit floating point number system, similar to the IEEE floating point...
Assume that you have a 12-bit floating point number system, similar to the IEEE floating point standard, with the format shown below and a bias of 7. The value of a floating point number in this system is represented as    FP = (-1)^S X 1.F X 2^(E-bias) for the floating point numbers A = 8.75 and B = -5.375. The binary representation of A is given as A = 0101 0000 1100 Show the hexidecimal representation of B.
Using the simple model for representing binary floating point numbers A floating-point number is 14 bits...
Using the simple model for representing binary floating point numbers A floating-point number is 14 bits in length. The exponent field is 5 bits. The significand field is 8 bits. The bias is 15 Represent -32.5010 in the simple model.
Concern the following 16-bit floating point representation: The first bit is the sign of the number...
Concern the following 16-bit floating point representation: The first bit is the sign of the number (0 = +, 1 = -), the next nine bits are the mantissa, the next bit is the sign of the exponent, and the last five bits are the magnitude of the exponent. All numbers are normalized, i.e. the first bit of the mantissa is one, except for zero which is all zeros. 1. What's the smallest difference between two consecutive or adjacent numbers?...
3. Write a java method that accepts a binary number and converts it to decimal then...
3. Write a java method that accepts a binary number and converts it to decimal then display the result. For Example: (110)2 = (6)10 (2 2 *1)+ (21 *1) + (20*0) = 6 Additional task: write a method that accepts a decimal and converts it to binary. i need to solve it as soon as and i will upvote you directly
Write a C++ program to perform two-4 bit binary number operations including addition and subtraction. The...
Write a C++ program to perform two-4 bit binary number operations including addition and subtraction. The user will type in two-4 bit binary numbers with the selection of one of the operations. Then, the program will calculate the result of the calculation. Display two-4 bit binary numbers and the result from the calculation.
Write a program that accepts a number of minutes and converts it both to hours and...
Write a program that accepts a number of minutes and converts it both to hours and days. For example, 6000 minutes is 100.0 hours or 4.166666666666667 days. (I currently have what is below) import java.util.Scanner; public class MinutesConversion { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numOfMinutes = sc.nextInt(); double hour = numOfMinutes/60.00; double days = (hour/24); System.out.println(numOfMinutes + " minutes is " + hour + " hours or " + days + " days.");...
Write a program that accepts a number of minutes and converts it to days and hours....
Write a program that accepts a number of minutes and converts it to days and hours. For example, 6000 minutes represents 4 days and 4 hours. Be sure to provide proper exception handling for non-numeric values and for negative values. Save the file as  MinuteConversionWithExceptionHandling.java
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT