When using std::atan2
, I get different results depending on whether I cross-compile for a 32-bit architecture rather than compiling for the (native) 64-bit.
$ cat test.cc
#include <cmath>
#include <stdio.h>
int main(int argc, char **argv) {
printf("%f\n", std::atan2(366.470947f, -116.213623f));
}
$ gcc test.cc -o test -lm -ffp-contract=off -ffloat-store
$ ./test
1.877880
$ gcc -m32 test.cc -o test -lm -ffp-contract=off -ffloat-store
$ ./test
1.877881
I was hoping for the results to be the same, since I'm porting an application over to 64-bit and require identical floating point results. As you can see I've already tried -ffp-contract=off -ffloat-store
which I'm aware can cause floating point inconsistency. Is there something else I'm missing? Or are the trig functions simply not standardized in this way?
I'm running Ubuntu 18.04.2, with gcc 7.5.0. CPU is a i7-1065G7.