diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2007-10-18 00:03:32 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2007-10-18 00:03:32 +0000 |
commit | 70317d8506a653b643a52e741442f506f23b24e4 (patch) | |
tree | 325d2d7106ff0ff058e4de57e25834e8683190e0 /newlib/libm/mathfp/sf_logarithm.c | |
parent | 923f9573a3f8e607b264575448ca520b3f228863 (diff) | |
download | cygnal-70317d8506a653b643a52e741442f506f23b24e4.tar.gz cygnal-70317d8506a653b643a52e741442f506f23b24e4.tar.bz2 cygnal-70317d8506a653b643a52e741442f506f23b24e4.zip |
2007-10-17 Jeff Johnston <jjohnstn@redhat.com>
* 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.
Diffstat (limited to 'newlib/libm/mathfp/sf_logarithm.c')
-rw-r--r-- | newlib/libm/mathfp/sf_logarithm.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/newlib/libm/mathfp/sf_logarithm.c b/newlib/libm/mathfp/sf_logarithm.c index b8564c14c..8aa85e880 100644 --- a/newlib/libm/mathfp/sf_logarithm.c +++ b/newlib/libm/mathfp/sf_logarithm.c @@ -38,12 +38,24 @@ _DEFUN (logarithmf, (float, int), int N; float f, w, z; - /* Check for domain error here. */ - if (x <= 0.0) + /* Check for domain/range errors here. */ + if (x == 0.0) { errno = ERANGE; return (-z_infinity_f.f); } + else if (x < 0.0) + { + errno = EDOM; + return (z_notanum_f.f); + } + else if (!isfinitef(x)) + { + if (isnanf(x)) + return (z_notanum_f.f); + else + return (z_infinity_f.f); + } /* Get the exponent and mantissa where x = f * 2^N. */ f = frexpf (x, &N); |