CS 101 - Assignment 1

CS 101 - Assignment 1
CS 101 - Assignment 1


Note:
     Don't copy paste

Solution:


A. 

To encode the decimal fraction -9/2 in 8-bit floating-point notation, we need to determine the sign, exponent, and mantissa components.

  1. Sign: Since the fraction is negative (-9/2), the sign bit will be 1.
  2. Exponent: To represent the exponent, we need to convert the exponent value to binary. The exponent field has 3 bits, so we need to find the binary representation of the exponent biased by the exponent bias value. In this case, the exponent bias is 2^(n-1) - 1, where n is the number of exponent bits. For 3 bits, the bias is 2^(3-1) - 1 = 3. The exponent value can be calculated as:
  3. -9/2 = -4.5 = -4 * 2^0 - 0.5 * 2^1
  4. Since -4 is represented as 100 in 2's complement, the biased exponent value will be 0 + 3 = 3, which is represented as 011 in binary.
  5. Mantissa: The mantissa represents the fractional part of the number. Since the mantissa field has 4 bits and needs to be normalized, we can determine the mantissa as follows:
  6. -9/2 = -4.5 = -1.125 * 2^2
  7. The normalized binary representation of the fractional part, 0.125, is 0010. Hence, the mantissa is 0010.

Putting it all together, the 8-bit floating-point representation of -9/2 using the given format is: 1 011 0010.


B. 

The smallest (lowest) negative value that can be represented using the 8-bit floating-point notation occurs when the sign bit is 1, the exponent is the minimum representable value (000), and the mantissa is the minimum representable value (0000). In this case, the exponent is biased by 3, so the actual exponent value is -3. The smallest negative value can be calculated as:

Sign * (1 + Mantissa) * 2^(Exponent - Bias)

= -1 * (1 + 0) * 2^(-3 - 3)

= -1 * 1/64

= -0.015625

Hence, the smallest negative value that can be represented using the 8-bit floating-point notation is approximately -0.015625.


C. 

The largest (highest) positive value that can be represented using the 8-bit floating-point notation occurs when the sign bit is 0, the exponent is the maximum representable value (111), and the mantissa is the maximum representable value (1111). In this case, the exponent is biased by 3, so the actual exponent value is 4. The largest positive value can be calculated as:

Sign * (1 + Mantissa) * 2^(Exponent - Bias)

= 1 * (1 + 1 - 1/16) * 2^(4 - 3)

= 1 * 1.9375 * 2

= 3.875

Hence, the largest positive value that can be represented using the 8-bit floating-point notation is approximately 3.875.


Some Important Links

  1.  MCM 301-Quiz 2
  2. Event Handling
  3. CS 201 GDB
  4. CS 302-GDB
  5. CS 408-Quiz 2
  6. CS610 - Computer Networks

THE END 😊