#include <stdio.h>
#include <cassert>
int main(){
const int nSize = 2048;
const float eps = 1e-5;
float x[nSize];
float res[nSize];
float y[nSize];
for(int i = 0; i < nSize; i++){
x[i] = 3.0;
y[i] = 10.0;
}
for(int i = 0; i < nSize; i++){
res[i] = powf(x[i], y[i]);
}
int j;
for(j = 0; j < nSize; j++){
auto diff = fabs(res[j] - 59049.000000f);
if(diff > eps){
printf("Res: %f; diff: %f; \n", res[j], diff);
break;
}
}
return 0;
}
GCC result:
59049.000000.
NCC result:
Res: 59048.996094; diff: 0.003906;
NCC result doesn't change behaviour with -fno-fast-math compiler option. With bigger operands - delta between gcc and ncc grows.
Scalar powf result perfectly matches gcc result.
GCC result:
59049.000000.NCC result:
Res: 59048.996094; diff: 0.003906;NCC result doesn't change behaviour with -fno-fast-math compiler option. With bigger operands - delta between gcc and ncc grows.
Scalar powf result perfectly matches gcc result.