<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="moz-cite-prefix">Am 22.11.18 um 18:30 schrieb Will
      Godfrey:<br>
    </div>
    <blockquote type="cite" cite="mid:20181122104526.3025c2cf@devuan">
      <pre class="moz-quote-pre" wrap="">While testing some mixed floating point and integer calculations I found a
quite surprising difference when this compiler option was set (gcc 6.x). It was
clearly different at only 100 iterations and got dramatically worse with
larger counts.

My test routine was this:

int a = 0;
float b = 0;
float c = 0;
float inc = 0.1f;
float dec = 0.05f;
int it = 100;
for (int i = 0; i < it; ++ i)
{
    a = (int)truncf(b);
    c = b - floorf(b);
    b += inc;
    a = (int)truncf(b);
    c = b - floorf(b);
    b -= dec;
}

cout << "int " << a << "  rem " << c << endl;

My suspicion is that the difference is due to accumulated rounding errors.

Curiously without the decrements the behavior with and without -ffast-math
seems to be identical well into the millions.

</pre>
    </blockquote>
    <p><br>
    </p>
    <p>In the guitarix project we've disabled  -ffast-math several years
      ago, when I remember right it was at gcc3, as it could lead to
      different un-reproduciable calculations. Last option I've disabled
      on gcc8 now, is <span class="gd" style="width: 1041px;">-ffinite-math-only,
        this one leads to nan's and inf's in several cases, which been
        as well not reproducible. <br>
      </span></p>
  </body>
</html>