Question

In: Computer Science

Q1: In the addition of floating-point numbers, how do we adjust the representation of numbers with...

Q1: In the addition of floating-point numbers, how do we adjust the representation of numbers with different exponents?

Q2:

Answer the following questions:

  1. What binary operation can be used to set bits? What bit pattern should the mask have?
  2. What binary operation can be used to unset bits? What bit pattern should the mask have?
  3. What binary operation can be used to flip bits? What bit pattern should the mask have?

Solutions

Expert Solution

1. To add two floating-point numbers firstly rewrite the smaller number such that the exponent matches the exponent of the larger number. For eg

Let's say we are adding 8.75 x 10-1 and 9.32 x 101 (these are in normalized)

So we have to rewrite 8.75 x 10-1 as 0.0875 x 101.

Now add the mantissa of the two numbers 0.0875 + 9.32 = 9.4075.

Now the final answer, in this case, is 9.4075 x 101. If the result of the addition isn't in normalized, you will have to normalize it.

2. To set let's say nth bit you have to left shift 1 till n times and or with the original number to set the nth bit, similarly, if you want to set let's say k bits you will have to create a number with those particular bits set to 1 and then or with the number.

For eg let's say the binary representation of the number is 000010 and you want to set 4th and 5th bit you would or it with 0110000, so the result after or operation will be 011010.

To unset let's say nth bit you have to take the number of the same number of bits as the original number and the bits which you want to unset as 0 and take and with the original number

For eg let's say the binary representation of the number is 011010 and you want to unset the 4th and the 5th bit you will and it with 100111, so the result would be 000010.

For flipping a number just take the negation of the number.

The negation of 000010 will be 111101


Related Solutions

Determine the IEEE single and double floating point representation of the following numbers: a) -26.25 b)...
Determine the IEEE single and double floating point representation of the following numbers: a) -26.25 b) 15/2
Determine the IEEE single and double floating point representation of the following numbers: a) (15/2) x...
Determine the IEEE single and double floating point representation of the following numbers: a) (15/2) x 2^50 b) - (15/2) x 2^-50 c) 1/5
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
c) Using the 32-bit binary representation for floating point numbers, represent the number 1011100110011 as a...
c) Using the 32-bit binary representation for floating point numbers, represent the number 1011100110011 as a 32 bit floating point number. i) A digital camera processes the images images in the real-world and stores them in binary form. Using the principles of digital signal processing, practically explain how this phenomenon occurs.
Consider the following 32-bit floating point representation based on the IEEE floating point standard: There is...
Consider the following 32-bit floating point representation based on the IEEE floating point standard: There is a sign bit in the most significant bit. The next eight bits are the exponent, and the exponent bias is 28-1-1 = 127. The last 23 bits are the fraction bits. The representation encodes number of the form V = (-1)S x M x 2E, where S is the sign, M is the significand, and E is the biased exponent. The rules for the...
[PYTHON] How do you write a program that first gets a list of floating point numbers...
[PYTHON] How do you write a program that first gets a list of floating point numbers from input. The input begins with an integer indicating the number of numbers that follow. Then input all data values and store them in a list [PYTHON]
Represent the following decimal numbers using IEEE-754 floating point representation. A. -0.375 B. -Infinity C. 17...
Represent the following decimal numbers using IEEE-754 floating point representation. A. -0.375 B. -Infinity C. 17 D. 5.25
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.
Convert the following number into 32bit IEEE 754 floating point representation. 0.000101
Convert the following number into 32bit IEEE 754 floating point representation. 0.000101
Under what conditions do floating point numbers represent something other than a number and what do...
Under what conditions do floating point numbers represent something other than a number and what do they then represent?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT