CS 473 HW 1 - Solutions

Sample solutions to cs473 HW1, Fall 2002

1.a.  Old Bit New        b.  Old Bit New     
      -----------            -----------     
      .25  0  .5             .125 0  .25     
      .5   1  .0             .25  0  .5      
                             .5   1  .0      
      Solution is 0.01       Solution is .001

  c.  Old Bit New        d.  Old   Bit New
      -----------            --------------
      .375 0  .75            .5625  1  .125
      .75  1  .5             .125   0  .25
      .5   1  .0             .25    0  .5
                             .5     1  .0
      Solution is .011       Solution is .1001

2.a.  Old  Bit  New      a.  Old   Bit  New
      -------------          --------------
      0     0                0      1   .5
      0     1   .5           .5     1   .75
      .5    0   .25          .75    0   .375
      .25   1   .625         .375   1   .6875
      Solution is .625       Solution is .6875

  c.  Old  Bit  New      d.  Old   Bit  New
      -------------          --------------
      0     1   .5           0      1   .5
      .5    1   .75          .5     1   .75
      .75   1   .875         .75    0   .375
      .875  0   .4375        .375   0   .1875
      Solution is .4375      Solution is .1875

3.a.  40700000 (hex)
      0100000001110-0 (binary)
      0 10000000 1110-0 (divided into fields)
      Sign: 0 means positive
      Exponent: 128 - 127 = 1
      Significand:  1.111
      
               1
      1.111 x 2  = 11.11

      Converting integer to decimal.
      Old  Bit  New
      -------------
        0   1     1
        2   1     3

      Converting fraction to decimal
      Old  Bit  New
      -------------
      0     1   .5
      .5    1   .75
      
      Solution is 3.75

  b.  c1560000 (hex)
      11000001010101100-0 (binary)
      1 10000010 10101100-0 (fields)

      Sign: 1 means negative
      Exponent:  130 - 127 = 3
      Significand: 1.101011
      
                  3
      1.101011 x 2  = 1101.011

      Converting integer to decimal
      Old  Bit  New
      -------------
        0   1     1
        2   1     3
        6   0     6
       12   1    13

       Converting fraction to decimal
       Old  Bit  New
       -------------
       0     1   .5
       .5    1   .75
       .375  0   .375

       Solution is -13.375

  c.  00000000 (hex)
      Special case:  solution is 0.

  d.  3f800000 (hex)
      0011111110000-0 (binary)
      0 01111111 0000-0 (fields)

      Sign:  0 means positive
      Exponent:  127 - 127 = 0
      Significand:  1.0

      This one can be give by inspection from here:  1.0

4.a.  37.25

      Convert integer part to binary
      Old New Bit
      -----------
       37  18  1
       18   9  0
        9   4  1
        4   2  0
        2   1  0
        1   0  1

      100101

      Convert fraction part to binary
      (this is problem 1.a)
      0.01
                                 0                5
      Significand:  100101.01 x 2  = 1.0010101 x 2
      Sign:  positive implies 0
      Exponent:  01111111 + 101 = 10000100
      
      0 10000100 00101010-0 (fields)
      0100 0010 0001 0101 0-0   (binary)
      42150000            (hexadecimal)

      Solution is 42150000

  b.  -9.125

      Integer:  9 -> 1001 (part of 4.a table)
      Fraction: .001 (problem 1.b)
      1001.001

                                0              3
      Significand:  1001.001 x 2 = 1.001001 x 2
      Sign:  negative implies 1
      Exponent: 01111111 + 11 = 10000010.

      1 10000010 0010010-0 (fields)
      1100 0001 0001 0010 0-0 (binary)
      c1120000 (hexadecimal)

      Solution is c1120000

  c.  0.375

      Integer:  0
      Fraction: .011 (problem 1.c)
      0.011
                            0          -2
      Significand:  .011 x 2  = 1.1 x 2
      Sign:  positive implies 0
      Exponent:  01111111 - 10 = 01111101

      0 01111101 10-0    (fields)
      0011 1110 1100 0-0 (binary)
      3ec00000           (hex)

      Solution is 3ec00000

  d.  -15.75

      Integer:
      Old New Bit
      -----------
       15   7  1
        7   3  1
        3   1  1
        1   0  1
        
        1111
        
      Fraction:
      Old Bit New
      -----------
      .75  1  .5
      .5   1  .0

        .11
                               0              3
      Significand:  1111.11 x 2  = 1.11111 x 2
      Sign: negative implies 1
      Exponent: 01111111 + 11 = 10000010

      1 10000010 111110-0 (fields)
      1100 0001 0111 1100-0 (binary)
      c17c0000 (hex)

      Solution is c17c0000

5.a.  41100000 / 40400000

      41100000 (hex)
      0100000100010-0 (binary)
      0 10000010 0010-0 (fields)
      
      Sign:  0
      Exponent: 10000010
      Significand: 1.001

      40400000 (hex)
      0100000001000-0 (binary)
      0 10000000 1000-0 (fields)

      Sign:  0
      Exponent: 10000000
      Significand: 1.1

      Subtract exponents:
       10000010
      -10000000
      ---------
             10
      +01111111
      ---------
       10000001
       
      Divide significands:
          0.11
         -------------
      1.1)1.001
          0.0 
          ----
          1.00
           .11
          ----
          0.011
           .011
           ----
           .000

      Renormalize:
      0.11 -> 1.1
      10000001
      -      1
      --------
      10000000

      Combine:
      0 10000000 10-0  (fields)
      0100 0000 0100-0 (binary)
      40400000         (hex)

      Solution is 40400000

  b.  41080000 * 40e80000

      41080000 (hex)
      0100 0001 0000 10000-0 (binary)
      0 10000010 00010000-0 (fields)

      Sign:  0
      Exponent: 10000010
      Significand:  1.0001

      40e80000 (hex)
      0100 0000 1110 1000 0-0 (binary)
      0 10000001 11010000-0 (fields)

      Sign:  0
      Exponent: 10000001
      Significand: 1.1101

      Add exponents:

       10000010
      +10000001
      ---------
      100000011
      -01111111
      ---------
       10000100

      Multiply significands
      1.1101
      1.0001
      ------
      1.1101
           11101
      -----------
      1.11101101

      (Result is already normalized)

      Combine:
      0 10000100 11101101  (fields)
      0100 0010 0111 0110 1  (binary)
      42768000            (hex)

      Solution is 42768000

  c.  3fe00000 + 3f000000

      3fe00000 (hex)
      0011 1111 1110 0-0 (binary)
      0 01111111 1100-0 (fields)

      Sign:  0
      Exponent: 01111111
      Significand: 1.11

      3f000000 (hex)
      0011 1111 0-0 (binary)
      0 01111110 0-0 (fields)

      Sign:  0
      Exponent: 01111110
      Significand: 1.0

      Adjust exponents:  shift second operand
      Exponent: 01111111
      Significand: 0.1

      Add significands
       1.11
      +0.1
      -----
      10.01

      Normalize:
      1.001
      Exponent: 01111111 + 1 = 10000000

      Combine:
      0 10000000 001 0-0 (fields)
      0100 0000 0001 0-0 (binary)
      40100000 (hex)

      Solution is 40100000

  d.  40700000 - 40200000

      40700000 (hex)
      0100 0000 0111 000 (binary)
      0 10000000 111000 (fields)

      Sign:  0
      Exponent: 10000000
      Significand: 1.111

      40200000 (hex)
      0100 0000 0010 0000 0-0 (binary)
      0 10000000 0100000 0-0 (fields)

      Sign:  0
      Exponent: 10000000
      Significand: 1.01

      Exponents are already aligned.

      Subtract significands:
      1.111
      1.01
      -----
      0.101

      Renormalize
      0.101 -> 1.01
      Exponent: 10000000 - 1 = 01111111

      Combine:
      0 01111111 010-0 (fields)
      0011 1111 1010-0 (binary)
      3fa00000 (hex)

      Solution is 3fa00000
      

      

Last modified: Tue Oct 15 12:19:07 MDT 2002