Math. 455-01 First Supplementary Assignment The following standard-conforming Fortran 90 program:
program test_bits_of_double
 implicit none
   integer i(2)
   integer ind, part
   double precision x

   x = -15d0
   call print_bits(x)
   x = +15d0
   call print_bits(x)
   x = 2d0**(-1023)
   call print_bits(x)
   x = 2d0**(-1024)
   call print_bits(x)

contains
   subroutine print_bits(x)
      double precision x
      write(*,'(1x,a,1x,d25.16,1x,a)') 'The bits for x = ', x, &
      'are:'
      i = transfer(x,i)
      do part=1,2
         do ind = 1,32
            write(*,'(1x,i1)',advance='no') ibits(i(part),32-ind,1)
         end do
      end do
      write(*,'(1x)',advance='yes')
      write(*,'(1x)',advance='yes')
   end subroutine print_bits
end program test_bits_of_double
gives the following output on a Sun Sparc 20, that conforms to IEEE 754 arithmetic:
interval% !f
f90 tp.f90 -o tp
Warning: tp.f90, line 13: Floating underflow in exponentiation
interval% !t
tp
 The bits for x =    -0.1500000000000000D+02 are:
 1 1 0 0 0 0 0 0 0 0 1 0 1 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 0 0 0 0 0 0 0

 The bits for x =     0.1500000000000000D+02 are:
 0 1 0 0 0 0 0 0 0 0 1 0 1 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 0 0 0 0 0 0 0

 The bits for x =     0.1112536929253601-307 are:
 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0

 The bits for x =     0.0000000000000000D+00 are:
 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

interval%

Explain fully the output to this program, based on what you know about IEEE 754 arithmetic.
Hint: Here is the definition of the Fortran 90 intrinsic procedures used in the program:
TRANSFER(SOURCE, MOLD [, SIZE])
Returns a result with a physical representation identical to that of SOURCE but interpreted with the type and type parameters of MOLD.
Arguments.

The result is of the same type and type parameters as MOLD.
Case (i): If MOLD is a scalar and SIZE is absent, the result is a scalar.
Case (ii): If MOLD is array valued and SIZE is absent, the result is array valued and of rank one. Its size is as small as possible such that its physical representation is not shorter than that of SOURCE.
Case (iii): If SIZE is present, the result is array valued of rank one and size SIZE.
Result Value. If the physical representation of the result has the same length as that of SOURCE, the physical representation of the result is that of SOURCE. If the physical representation of the result is longer than that of SOURCE, the physical representation of the leading part is that of SOURCE and the remainder is undefined. If the physical representation of the result is shorter than that of SOURCE, the physical representation of the result is the leading part of SOURCE. If D and E are scalar variables such that the physical representation of D is as long as or longer than that of E, the value of TRANSFER (TRANSFER (E, D), E) shall be the value of E. IF D is an array and E is an array of rank one, the value of TRANSFER (TRANSFER (E, D), E, SIZE (E)) shall be the value of E.
Example
TRANSFER (1082130432, 0.0) has the value 4.0 on a processor that represents the values 4.0 and 1082130432 as the string of binary digits 0100 0000 1000 0000 0000 0000 0000 0000.
IBITS (I, POS, LEN)
Extracts a sequence of bits.
Arguments.
I shall be of type integer.
POS shall be of type integer. It shall be nonnegative and POS + LEN shall be less than or equal to BIT_SIZE (I).
LEN shall be of type integer and nonnegative.
Result Characteristics. Same as I.
Result Value. The result has the value of the sequence of LEN bits in I beginning at bit POS, right-adjusted and with all other bits zero. The model for the interpretation of an integer value as a sequence of bits is in 13.5.7.
Example. IBITS (14, 1, 3) has the value 7.
Contact the instructor if you have any questions about this.