Mercurial > hg > octave-lyh > gnulib-hg
changeset 16469:d2bb16b4df01
modfl-ieee: Fix test failures.
* lib/modfl.c (modfl): Treat NaN and Inf specially.
* modules/modfl (Depends-on): Add isfinite, isinf.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 27 Feb 2012 04:03:02 +0100 |
parents | 5ad3cc13d9c3 |
children | 2b6492cddc6a |
files | ChangeLog lib/modfl.c modules/modfl |
diffstat | 3 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 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
--- a/lib/modfl.c +++ b/lib/modfl.c @@ -35,9 +35,25 @@ 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
--- a/modules/modfl +++ b/modules/modfl @@ -9,7 +9,9 @@ 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