* math/w_fmodf.c: Likewise.
* math/w_fmodl.c: Likewise.
* math/libm-test.inc (fmod_test): Add tests for errno after calls for
x=±Inf or y=0.
2009-04-25 Ulrich Drepper <drepper@redhat.com>
+ * math/w_fmod.c: Also handle x=±Inf as error.
+ * math/w_fmodf.c: Likewise.
+ * math/w_fmodl.c: Likewise.
+ * math/libm-test.inc (fmod_test): Add tests for errno after calls for
+ x=±Inf or y=0.
+
* sysdeps/i386/fpu/s_cos.S: Set errno for ±Inf.
* sysdeps/i386/fpu/s_cosf.S: Likewise.
* sysdeps/i386/fpu/s_cosl.S: Likewise.
TEST_ff_f (fmod, minus_zero, 3, minus_zero);
/* fmod (+inf, y) == NaN plus invalid exception. */
+ errno = 0;
TEST_ff_f (fmod, plus_infty, 3, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for fmod(Inf,3) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (-inf, y) == NaN plus invalid exception. */
+ errno = 0;
TEST_ff_f (fmod, minus_infty, 3, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for fmod(-Inf,3) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (x, +0) == NaN plus invalid exception. */
+ errno = 0;
TEST_ff_f (fmod, 3, 0, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for fmod(3,0) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (x, -0) == NaN plus invalid exception. */
TEST_ff_f (fmod, 3, minus_zero, nan_value, INVALID_EXCEPTION);
double z;
z = __ieee754_fmod(x,y);
if(_LIB_VERSION == _IEEE_ ||__isnan(y)||__isnan(x)) return z;
- if(y==0.0) {
- return __kernel_standard(x,y,27); /* fmod(x,0) */
+ if(__isinf(x)||y==0.0) {
+ /* fmod(+-Inf,y) or fmod(x,0) */
+ return __kernel_standard(x,y,27);
} else
return z;
#endif
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
static char rcsid[] = "$NetBSD: w_fmodf.c,v 1.3 1995/05/10 20:48:57 jtc Exp $";
#endif
-/*
+/*
* wrapper fmodf(x,y)
*/
float z;
z = __ieee754_fmodf(x,y);
if(_LIB_VERSION == _IEEE_ ||__isnanf(y)||__isnanf(x)) return z;
- if(y==(float)0.0) {
- /* fmodf(x,0) */
+ if(__isinff(x)||y==(float)0.0) {
+ /* fmodf(+-Inf,y) or fmodf(x,0) */
return (float)__kernel_standard((double)x,(double)y,127);
} else
return z;
long double z;
z = __ieee754_fmodl(x,y);
if(_LIB_VERSION == _IEEE_ ||__isnanl(y)||__isnanl(x)) return z;
- if(y==0.0) {
- return __kernel_standard(x,y,227); /* fmod(x,0) */
+ if(__isinfl(x)||y==0.0) {
+ /* fmodl(+-Inf,y) or fmodl(x,0) */
+ return __kernel_standard(x,y,227);
} else
return z;
#endif