From 70317d8506a653b643a52e741442f506f23b24e4 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 18 Oct 2007 00:03:32 +0000 Subject: 2007-10-17 Jeff Johnston * libm/mathfp/s_logarithm.c: Fix error introduced by previous fix when handling negative input values. Make function consistent with math directory and glibc version such that inf and nan values return inf and nan respectively with no errno setting. * libm/mathfp/sf_logarithm.c: Ditto. * libm/math/w_log.c: Set errno to ERANGE when input is 0.0. * libm/math/wf_log.c: Ditto. * libm/math/w_log10.c: Ditto. * libm/math/wf_log10.c: Ditto. --- newlib/libm/mathfp/s_logarithm.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'newlib/libm/mathfp/s_logarithm.c') diff --git a/newlib/libm/mathfp/s_logarithm.c b/newlib/libm/mathfp/s_logarithm.c index 661dd8818..51e7f3066 100644 --- a/newlib/libm/mathfp/s_logarithm.c +++ b/newlib/libm/mathfp/s_logarithm.c @@ -100,12 +100,24 @@ _DEFUN (logarithm, (double, int), int N; double f, w, z; - /* Check for domain error here. */ - if (x <= 0.0) + /* Check for range and domain errors here. */ + if (x == 0.0) { errno = ERANGE; return (-z_infinity.d); } + else if (x < 0.0) + { + errno = EDOM; + return (z_notanum.d); + } + else if (!isfinite(x)) + { + if (isnan(x)) + return (z_notanum.d); + else + return (z_infinity.d); + } /* Get the exponent and mantissa where x = f * 2^N. */ f = frexp (x, &N); -- cgit v1.2.3