Fix rounding issues with sqrt/sqrtf

- compiler is sometimes optimizing out the rounding check in
  e_sqrt.c and ef_sqrt.c which uses two constants to create
  an inexact operation
- there is a similar constant operation in s_tanh.c/sf_tanh.c
- make the one and tiny constants volatile to stop this
This commit is contained in:
Jeff Johnston 2021-06-04 14:36:38 -04:00
parent dfe5988f96
commit a9165ea07c
4 changed files with 8 additions and 8 deletions

View File

@ -86,9 +86,9 @@
#ifndef _DOUBLE_IS_32BITS #ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__ #ifdef __STDC__
static const double one = 1.0, tiny=1.0e-300; static const volatile double one = 1.0, tiny=1.0e-300;
#else #else
static double one = 1.0, tiny=1.0e-300; static double volatile one = 1.0, tiny=1.0e-300;
#endif #endif
#ifdef __STDC__ #ifdef __STDC__

View File

@ -16,9 +16,9 @@
#include "fdlibm.h" #include "fdlibm.h"
#ifdef __STDC__ #ifdef __STDC__
static const float one = 1.0, tiny=1.0e-30; static const volatile float one = 1.0, tiny=1.0e-30;
#else #else
static float one = 1.0, tiny=1.0e-30; static float volatile one = 1.0, tiny=1.0e-30;
#endif #endif
#ifdef __STDC__ #ifdef __STDC__

View File

@ -73,9 +73,9 @@ PORTABILITY
#ifndef _DOUBLE_IS_32BITS #ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__ #ifdef __STDC__
static const double one=1.0, two=2.0, tiny = 1.0e-300; static const volatile double one=1.0, two=2.0, tiny = 1.0e-300;
#else #else
static double one=1.0, two=2.0, tiny = 1.0e-300; static double volatile one=1.0, two=2.0, tiny = 1.0e-300;
#endif #endif
#ifdef __STDC__ #ifdef __STDC__

View File

@ -16,9 +16,9 @@
#include "fdlibm.h" #include "fdlibm.h"
#ifdef __STDC__ #ifdef __STDC__
static const float one=1.0, two=2.0, tiny = 1.0e-30; static const volatile float one=1.0, two=2.0, tiny = 1.0e-30;
#else #else
static float one=1.0, two=2.0, tiny = 1.0e-30; static volatile float one=1.0, two=2.0, tiny = 1.0e-30;
#endif #endif
#ifdef __STDC__ #ifdef __STDC__