I reduced my problem to the following code:

int main (void)
{
  double x;

  x = 1 / 3.;
  __builtin_printf ("%.30lg %.30lg\n", __builtin_remainder(1., 1/3.), 1/3.);
  __builtin_printf ("%.30lg %.30lg\n", __builtin_remainder(1., x), x);
}

This calls __builtin_remainder() twice, once with constant arguments, once with 
a variable. Without rounding math, the two results agree (5.55e-17), but with 
-frounding-math, the constant case changes (-2.71e-20).

On x86_64-apple-darwin, things are even weirder than x86_64-linux (the above): 
constant-case with -frounding-math -m64 is unchanged, while constant case with 
-frounding-math -m32 follows the linux results.

I don’t think this is right, since remainder() is supposed to be unaffected by 
the rounding mode. Yet, before I open a PR, I wanted to see if someone 
understands what’s going on…

Any ideas?

FX

Reply via email to