! Last change: DOS 24 Jul 2000 8:23 pm ! *** copyright 2000 *** ! *** filename floatex.f95 *** John F. Monahan ** ! ********************** program floatex ! write out the internal representations of floating ! point numbers -- these will be ieee standard implicit none integer i,j real x real, dimension(7) :: xl ! ! equivalence means use same storage for both variables equivalence (x,i) ! data xl /1.0,-1.0,.0,-15.,1.2e-38,.15e-44,3.4e+38/ ! compiler may be picky about .14 or .15 cutoff ! for smallest unnormalized number ! ! write out as floating point, internal representation ! and lastly as fixed point 20 format(4x,'floating pt internal (z) fixed point') 21 format(4x,e12.4,4x,z8,4x,i12) ! some compilers will only write integers in z ! ! write the output here open ( UNIT=6, FILE='floatex.out' ) ! write(6,20) ! write seven interesting numbers do j = 1,7 x = xl(j) write(6,21) x,i,i ! write same number three ways end do ! loop on j ! ! the last ones as hex constants ! *** different compilers have different ways of writing *** ! ** or assigning hexadecimal constants ** ! i = z'7f7fffff' ! largest floating point number write(6,21) x,i,i i = z'7f800000' ! infinity write(6,21) x,i,i i = z'7fffffff' ! not-a-number -- 'NaN' write(6,21) x,i,i stop end program floatex ! *** end of filename floatex.f95 *********************