https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67531

--- Comment #3 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
(In reply to Pat Haugen from comment #2)
> pthaugen@genoa:~$ ~/install/gcc/trunk/bin/gcc z.c -lm && ./a.out
> 0.3333333333333333333333333333333353876586
> 0.3333333333333333333333333333333292246827

How about with this? I'm trying to come as close as possible to the exact
sequence of fe.etround() calls as the Fortran front-end and runtime library
would end up performing…


#include <fenv.h>
#include <stdio.h>

int main (void)
{
  int r;
  long double x1, x2, x;

  x1 = 1;
  x = 3;
  r = fegetround ();
  fesetround (FE_UPWARD);
  x1 = x1 / x;
  fesetround (r);

  x2 = 1;
  x = 3;
  r = fegetround ();
  fesetround (FE_DOWNWARD);
  x2 = x2 / x;
  fesetround (r);

  printf ("%.40Lg\n", x1);
  printf ("%.40Lg\n", x2);
}

Reply via email to