The y0, y1 and yn functions need separate conditions when x is zero as
that returns ERANGE instead of EDOM.
Also stop adjusting the return value from the __ieee754_y* functions
as that is already correct and we were just breaking it.
Signed-off-by: Keith Packard <keithp@keithp.com>
double z;
z = __ieee754_y0(x);
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0){
- /* y0(0) = -inf or y0(x<0) = NaN */
+ if(x < 0.0){
+ /* y0(x<0) = NaN */
errno = EDOM;
- return -HUGE_VAL;
+ }
+ if(x == 0.0){
+ /* y0(0) = -inf */
+ errno = ERANGE;
}
if(x>X_TLOSS) {
/* y0(x>X_TLOSS) */
errno = ERANGE;
- return 0.0;
- } else
- return z;
+ }
+ return z;
#endif
}
double z;
z = __ieee754_y1(x);
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0){
- /* y1(0) = -inf or y1(x<0) = NaN */
+ if(x < 0.0){
+ /* y1(x<0) = NaN */
errno = EDOM;
- return -HUGE_VAL;
+ }
+ if(x == 0.0){
+ /* y1(0) = -inf */
+ errno = ERANGE;
}
if(x>X_TLOSS) {
/* y1(x>X_TLOSS) */
errno = ERANGE;
- return 0.0;
- } else
- return z;
+ }
+ return z;
#endif
}
double z;
z = __ieee754_yn(n,x);
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0){
- /* yn(n,0) = -inf or yn(x<0) = NaN */
+ if(x < 0.0){
+ /* yn(x<0) = NaN */
errno = EDOM;
- return -HUGE_VAL;
+ }
+ if(x == 0.0){
+ /* yn(0) = -inf */
+ errno = ERANGE;
}
if(x>X_TLOSS) {
/* yn(x>X_TLOSS) */
errno = ERANGE;
- return 0.0;
- } else
- return z;
+ }
+ return z;
#endif
}
if(fabsf(x)>(float)X_TLOSS) {
/* j0f(|x|>X_TLOSS) */
errno = ERANGE;
- return 0.0f;
- } else
- return z;
+ }
+ return z;
#endif
}
float z;
z = __ieee754_y0f(x);
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= (float)0.0){
- /* y0f(0) = -inf or y0f(x<0) = NaN */
+ if(x < 0.0f){
+ /* y0f(x<0) = NaN */
errno = EDOM;
- return -HUGE_VALF;
}
+ if (x == 0.0f){
+ /* y0f(n,0) = -inf */
+ errno = ERANGE;
+ }
if(x>(float)X_TLOSS) {
/* y0f(x>X_TLOSS) */
errno = ERANGE;
- return 0.0f;
- } else
- return z;
+ }
+ return z;
#endif
}
float z;
z = __ieee754_y1f(x);
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0f){
- /* y1f(0) = -inf or y1f(x<0) = NaN */
+ if(x < 0.0f){
+ /* y1f(x<0) = NaN */
errno = EDOM;
- return -HUGE_VALF;
}
+ if (x == 0.0f){
+ /* y1f(n,0) = -inf */
+ errno = ERANGE;
+ }
if(x>(float)X_TLOSS) {
/* y1f(x>X_TLOSS) */
errno = ERANGE;
- return 0.0f;
- } else
- return z;
+ }
+ return z;
#endif
}
if(fabsf(x)>(float)X_TLOSS) {
/* jnf(|x|>X_TLOSS) */
errno = ERANGE;
- return 0.0f;
- } else
- return z;
+ }
+ return z;
#endif
}
float z;
z = __ieee754_ynf(n,x);
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0f){
- /* ynf(n,0) = -inf or ynf(x<0) = NaN */
+ if(x < 0.0f){
+ /* ynf(x<0) = NaN */
errno = EDOM;
- return -HUGE_VALF;
}
+ if (x == 0.0f){
+ /* ynf(n,0) = -inf */
+ errno = ERANGE;
+ }
if(x>(float)X_TLOSS) {
/* ynf(x>X_TLOSS) */
errno = ERANGE;
- return 0.0f;
- } else
- return z;
+ }
+ return z;
#endif
}