Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libm/mathfp/s_logarithm.c')
-rw-r--r--newlib/libm/mathfp/s_logarithm.c16
1 files changed, 14 insertions, 2 deletions
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);