* lib/modfl.c (modfl): Treat NaN and Inf specially.
* modules/modfl (Depends-on): Add isfinite, isinf.
2012-02-26 Bruno Haible <bruno@clisp.org>
+ modfl-ieee: Fix test failures.
+ * lib/modfl.c (modfl): Treat NaN and Inf specially.
+ * modules/modfl (Depends-on): Add isfinite, isinf.
+
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
* m4/modff-ieee.m4: New file.
* m4/modff.m4 (gl_FUNC_MODFF): If gl_FUNC_MODFF_IEEE is present, test
long double
modfl (long double x, long double *iptr)
{
- long double integer_part = truncl (x);
- *iptr = integer_part;
- return x - integer_part;
+ if (isfinite (x))
+ {
+ long double integer_part = truncl (x);
+ *iptr = integer_part;
+ return x - integer_part;
+ }
+ else
+ {
+ if (isinf (x))
+ {
+ *iptr = x;
+ return 1.0L / x;
+ }
+ else /* isnanl (x) */
+ {
+ *iptr = x;
+ return x;
+ }
+ }
}
#endif
Depends-on:
math
modf [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+isfinite [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
truncl [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+isinf [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
configure.ac:
gl_FUNC_MODFL