i am trying to port a particular piece of code from solaris to Linux. During the process i found that the precision on linux is different and it is in extended precision and we need to set it to double precision explicitly. To achieve this found fpu_control.h library, functions FPU_GETCW and FPU_SETCW functions. But even after that the precision is not being set properly. the code snippet
long double power = 1.0;
#ifdef __linux
fpu_control_t mask;
_FPU_GETCW(mask);
mask &= ~(_FPU_EXTENDED & _FPU_SINGLE);
mask |= _FPU_DOUBLE;
_FPU_SETCW(mask);
power *= 0.1;
#endif
when i print power the value is power = 0.1000000000000000055511151231257827
however I was expecting power to have an value 0.1 Also i have use -DDouble while compiling. Can someone point me whats going wrong.