This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible explaination why large_real_kind_form_io_2.f90 is failing on PPC/OSX


> Can you print out the values of x and y?

  0.5403023058681397650104827334871516        0.540302305868140     

looks normal to me. I suspect the problem comes from

  y = (real8) (x - (real16) y);

in the dump. I have tried the following code:

real(16) :: x, z
real(8)  :: y
x = 1.0_16
y = 1.0_8
x = f16(x)
y = f8(y)
print *, x, y
z = y
print *, z, y
print *, z-x
end
real(16) function f16(x)
real(16) :: x
f16 = x/3.0_16
end
real(8) function f8(y)
real(8) :: y
f8 = y/3.0_8
end

so no intrinsic functions and I get:

  0.3333333333333333148296162562473910        0.333333333333333     
  0.3333333333333333148296162562473910        0.333333333333333     
   0.000000000000000000000000000000000      

so the diff is now 0 as expected, but I don't understand why
1.0_16/3.0_16 can give 0.3333333333333333148296162562473910
and not 0.3333333333333333333333333333333333. The dump is

MAIN__ ()
{
  real16 z;
  real8 y;
  real16 x;

  _gfortran_set_std (70, 127, 0);
  x = 1.0e+0;
  y = 1.0e+0;
  x = (real16) f16 (&x);
  y = (real8) f8 (&y);
  {
    struct __st_parameter_dt dt_parm.0;

    dt_parm.0.common.filename = "diff_8_16.f90";
    dt_parm.0.common.line = 7;
    dt_parm.0.common.unit = 6;
    dt_parm.0.common.flags = 128;
    _gfortran_st_write (&dt_parm.0);
    _gfortran_transfer_real (&dt_parm.0, &x, 16);
    _gfortran_transfer_real (&dt_parm.0, &y, 8);
    _gfortran_st_write_done (&dt_parm.0);
  }
  z = (real16) y;
  {
    struct __st_parameter_dt dt_parm.1;

    dt_parm.1.common.filename = "diff_8_16.f90";
    dt_parm.1.common.line = 9;
    dt_parm.1.common.unit = 6;
    dt_parm.1.common.flags = 128;
    _gfortran_st_write (&dt_parm.1);
    _gfortran_transfer_real (&dt_parm.1, &z, 16);
    _gfortran_transfer_real (&dt_parm.1, &y, 8);
    _gfortran_st_write_done (&dt_parm.1);
  }
  {
    struct __st_parameter_dt dt_parm.2;

    dt_parm.2.common.filename = "diff_8_16.f90";
    dt_parm.2.common.line = 10;
    dt_parm.2.common.unit = 6;
    dt_parm.2.common.flags = 128;
    _gfortran_st_write (&dt_parm.2);
    {
      real16 D.955;

      D.955 = z - x;
      _gfortran_transfer_real (&dt_parm.2, &D.955, 16);
    }
    _gfortran_st_write_done (&dt_parm.2);
  }
}


f16 (x)
{
  real16 __result_f16;

  __result_f16 = *x / 3.0e+0;
  return __result_f16;
}


f8 (y)
{
  real8 __result_f8;

  __result_f8 = *y / 3.0e+0;
  return __result_f8;
}

Dominique


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]