CSCI 370 Computer Architecture: Homework 3 Solutions

Due date (firm): On or before Thursday, April 10, 2025
Absolutely no copying others’ works
Name: Professor Hu

  1. (Floating-point representation: 20%) What decimal number does the hexadecimal number (A63D 8C00 0000 0000)16 represent if it is a floating point number? Use the IEEE 754 standard.
    Ans>
      1 0 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

      Sign = 1 is negative.
      Exponent = 010011000112 = 20 + 21 + 25 + 26 + 29 = 1 + 2 + 32 + 64 + 512 = 611
      E - bias = 611 - 1023 = -412
      Significand = 1.11011000110000000...2 = 1 + 2-1 + 2-2 + 2-4 + 2-5 + 2-9 + 2-10
            = 1 + 0.5 + 0.25 + 0.0625 + 0.03125 + 0.001953125 + 0.0009765 = 1.8466796
      Therefore, the value in decimal is -1.8466796 × 2-412


  2. (Floating-point arithmetic: 80%) IEEE 754-2008 contains a half precision that is only 16 bits wide. The leftmost bit is still the sign bit, the exponent is 5 bits wide and has a bias of 15, and the mantissa is 10 bits long. A hidden 1 is assumed. Assuming the three numbers, A=10.44373, B=1.28627, and C=9.784379, are stored in the 16-bit IEEE 754-2008 format, calculate A×B-C by hand. Assume 1 guard bit, 1 round bit, and 1 sticky bit, and round to the nearest even (only on the Step 4. Rounding the Significand). Show all the steps in normalized floating point numbers with 11 bits of precision (or 10 bits of fraction); i.e., (-1)S×(1.F)2×2E, where S is the sign bit, |F|=10, and E is without including the bias. Note that

    • have to show all five steps step-by-step,
    • the calculation should be similar to those in Slide 10.11 and Slide 10.16; i.e., the numbers should use a base-2 scientific notation and include 3 extra bits each (e.g., IEEE format and bias need NOT be used),
    • to answer this question, simulate the hardware by including 3 extra bits for each operand and result and using the 3 extra bits as possible as you could,
    • if the number has to be shifted to the right on the Step 1. Making Exponents Equal, round (just using the regular rounding method) the number to 10 bits of fraction and 3 extra bits before calculation,
    • rounding to the nearest even will be applied only once after finishing all calculation because the 3 extra bits need to be kept for further calculation, and
    • 2’s complement representation has to be used if needed.

    Ans>
      1.    10.44373
         = 1010.011100011001...2
         = 1.010011100011001...2 × 23 (normalized)
         = 1.0100111000 1 1 12 × 23 (Guard=1, Round=1, Sticky=1)
        
        because
        
         10 ÷ 2 ⇒ Q: 5; R: 0
          5 ÷ 2 ⇒ Q: 2; R: 1
          2 ÷ 2 ⇒ Q: 1; R: 0
          1 ÷ 2 ⇒ Q: 0; R: 1
        
         So, 10 = 10102
        
         0.44373 × 2 = 0.88746 ⇒ 0
         0.88746 × 2 = 1.77492 ⇒ 1
         0.77492 × 2 = 1.54984 ⇒ 1
         0.54984 × 2 = 1.09968 ⇒ 1
         0.09968 × 2 = 0.19936 ⇒ 0
         0.19936 × 2 = 0.39872 ⇒ 0
         0.39872 × 2 = 0.79744 ⇒ 0
         0.79744 × 2 = 1.59488 ⇒ 1
         0.59488 × 2 = 1.18976 ⇒ 1
         0.18976 × 2 = 0.37952 ⇒ 0
         0.37952 × 2 = 0.75904 ⇒ 0
         0.75904 × 2 = 1.51808 ⇒ 1
         ...
        
         So, 0.44373 = 0.011100011001...2

      2.    1.28627
         = 1.01001001010010...2
         = 1.01001001010010...2 × 20 (normalized)
         = 1.0100100101 0 0 12 × 20 (Guard=0, Round=0, Sticky=1)
        
        because
        
         0.28627 × 2 = 0.57254 ⇒ 0
         0.57254 × 2 = 1.14508 ⇒ 1
         0.14508 × 2 = 0.29016 ⇒ 0
         0.29016 × 2 = 0.58032 ⇒ 0
         0.58032 × 2 = 1.16064 ⇒ 1
         0.16064 × 2 = 0.32128 ⇒ 0
         0.32128 × 2 = 0.64256 ⇒ 0
         0.64256 × 2 = 1.28512 ⇒ 1
         0.28512 × 2 = 0.57024 ⇒ 0
         0.57024 × 2 = 1.14048 ⇒ 1
         0.14048 × 2 = 0.28096 ⇒ 0
         0.28096 × 2 = 0.56192 ⇒ 0
         0.56192 × 2 = 1.12384 ⇒ 1
         0.12384 × 2 = 0.24768 ⇒ 0
         ...
        
         So, 0.28627 = 0.01001001010010...2

      3.    9.784379
         = 1001.11001000110011...2
         = 1.00111001000110011...2 × 23 (normalized)
         = 1.0011100100 0 1 12 × 23 (Guard=0, Round=1, Sticky=1)
        
        because
        
         0.784379 × 2 = 1.568758 ⇒ 1
         0.568758 × 2 = 1.137516 ⇒ 1
         0.137516 × 2 = 0.275032 ⇒ 0
         0.275032 × 2 = 0.550064 ⇒ 0
         0.550064 × 2 = 1.100128 ⇒ 1
         0.100128 × 2 = 0.200256 ⇒ 0
         0.200256 × 2 = 0.400512 ⇒ 0
         0.400512 × 2 = 0.801024 ⇒ 0
         0.801024 × 2 = 1.602048 ⇒ 1
         0.602048 × 2 = 1.204096 ⇒ 1
         0.204096 × 2 = 0.408192 ⇒ 0
         0.408192 × 2 = 0.816384 ⇒ 0
         0.816384 × 2 = 1.632768 ⇒ 1
         0.632768 × 2 = 1.265536 ⇒ 1
         ...
        
         So, 0.784379 = 0.11001000110011...2
            

        A × B
      = 10.44373 × 1.28627
      = (1.0100111000 1 1 12 × 23) × (1.0100100101 0 0 12 × 20)
      Step 1. Calculating the exponent of the product
         3 + 0 = 3
      Step 2. Multiplying the significands
                       1.0100111000111
       ×               1.0100100101001
      ————————————————————————————————
                        10100111000111
                       00000000000000
                      00000000000000
                     10100111000111
                    00000000000000
                   10100111000111
                  00000000000000
                 00000000000000
                10100111000111
               00000000000000
              00000000000000
             10100111000111
            00000000000000
       +   10100111000111
      ————————————————————————————————
           110101101111000111111011111  or
          1.10101101111000111111011111
         (1.0100111000 1 1 12 × 23) × (1.0100100101 0 0 12 × 20)
       = 1.101011011110001111110111112 × 23
      Step 3. Normalizing the product
         1.101011011110001111110111112 × 23
       ≈ 1.1010110111 1 0 12 × 23 (Guard=1, Round=0, Sticky=1)

         A × B - C
      = (1.1010110111 1 0 12 × 23) - (1.0011100100 0 1 12 × 23)
      Step 1. Making exponents equal
            Do nothing.

      Step 2. Performing subtraction
          1.1010110111 1 0 12 × 23 (Guard=1, Round=0, Sticky=1)
       -  1.0011100100 0 1 12 × 23 (Guard=0, Round=1, Sticky=1)
                                   ⇓
         01.1010110111 1 0 12 × 23
       + 10.1100011011 1 0 12 × 23 (2’s complement)
      ————————————————————————————————————————————
       1 00.0111010011 0 1 02 × 23 (Guard=0, Round=1, Sticky=0)
      Step 3. Normalizing the difference
          0.0111010011 0 1 02 × 23 (Guard=0, Round=1, Sticky=0)
        ≈ 1.1101001101 0 02   × 21 (Round=0, Sticky=0)
      Step 4. Rounding the significand
          1.1101001101 0 02 × 21 (Round=0, Sticky=0)
        = 1.11010011012     × 21
      Step 5. Checking for overflow or underflow
          1.11010011012 × 21
       = 11.1010011012
       =  21 + 20 + 2-1 + 2-3 + 2-6 + 2-7 + 2-9 
       =  2 + 1 + 0.5 + 0.125 + 0.015625 + 0.0078125 + 0.0019531
       =  3.6503906
       ≈  10.44373 × 1.28627 - 9.784379
       =  3.6490776