Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

Can this piece of code be modified such that it works with fast-math enabled?

$
0
0

Can the code below be modified such that it works correctly even when compiled by GCC with fast-math enabled?

#include <iostream>#include <float.h>using namespace std;int main(){  char divider = 2;  float power = 1;  float number = 1;  float current = number + power;  cout.precision(20);  // Divide until rounded off  while(current != number)  {    power /= divider;    current = number + power;    //cout << current << endl;  }  cout << power * divider << endl;  cout << FLT_EPSILON << endl;}

Note: I have it in a header file and I haven't managed to turn off fast math for the header. See Strange while loop behavior and How to disable fast math for a header file function


Viewing all articles
Browse latest Browse all 22016

Trending Articles