single to double conversion

Dominique Dhumieres dominiq@lps.ens.fr
Wed Sep 27 18:57:00 GMT 2006


I have done some tests on a modified version:

      program main
      real*8 number,ran_u,ran_d
      number=ran_u()   !!number will be TRASH!! contain random memory bits, etc
      print *,number
      number=ran_d()   
      print *,number
      end
      function ran_u()
      real ran_u
      ran_u=42.42d0
      end
      function ran_d()
      real*8 ran_d
      ran_d=42.42d0
      end

All the compilers I have on my G5/OSX (g77, xlf, g95, gfortran) give
some variant of:

 42.4199981689453125
 42.4200000000000017

The same test on AMD give

  5.484265999324755E-315
   42.4200000000000     

for gfortran, g95, Portland Group Fortran
and

   42.4199981689453     
   42.4200000000000     

for g77, gfortran  -ff2c, and Intel Fortran.

Dominique



More information about the Fortran mailing list