aboutsummaryrefslogtreecommitdiff
path: root/math/s_clog10f.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-07-26 11:31:35 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-07-26 11:31:35 +0000
commitda865e95bcf9a5365de78fa6b5c681aca0a1bb46 (patch)
tree783e2a5f2befa846dc208ec14b7dcde164c7b205 /math/s_clog10f.c
parent3129cfc6ec7be65a0bdc1f82432ee421c1c65a77 (diff)
downloadglibc-da865e95bcf9a5365de78fa6b5c681aca0a1bb46.tar
glibc-da865e95bcf9a5365de78fa6b5c681aca0a1bb46.tar.gz
glibc-da865e95bcf9a5365de78fa6b5c681aca0a1bb46.tar.bz2
glibc-da865e95bcf9a5365de78fa6b5c681aca0a1bb46.zip
Improve clog, clog10 handling of values with real or imaginary part 1 (bug 13629).
Diffstat (limited to 'math/s_clog10f.c')
-rw-r--r--math/s_clog10f.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/math/s_clog10f.c b/math/s_clog10f.c
index 5a0c370de5..eb1b895aec 100644
--- a/math/s_clog10f.c
+++ b/math/s_clog10f.c
@@ -44,21 +44,21 @@ __clog10f (__complex__ float x)
{
/* Neither real nor imaginary part is NaN. */
float absx = fabsf (__real__ x), absy = fabsf (__imag__ x);
- float d;
int scale = 0;
+ if (absx < absy)
+ {
+ float t = absx;
+ absx = absy;
+ absy = t;
+ }
+
if (absx > FLT_MAX / 2.0f)
{
scale = -1;
absx = __scalbnf (absx, scale);
absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f);
}
- else if (absy > FLT_MAX / 2.0f)
- {
- scale = -1;
- absx = (absx >= FLT_MIN * 2.0f ? __scalbnf (absx, scale) : 0.0f);
- absy = __scalbnf (absy, scale);
- }
else if (absx < FLT_MIN && absy < FLT_MIN)
{
scale = FLT_MANT_DIG;
@@ -66,9 +66,29 @@ __clog10f (__complex__ float x)
absy = __scalbnf (absy, scale);
}
- d = __ieee754_hypotf (absx, absy);
+ if (absx == 1.0f && scale == 0)
+ {
+ float absy2 = absy * absy;
+ if (absy2 <= FLT_MIN * 2.0f * (float) M_LN10)
+ {
+#if __FLT_EVAL_METHOD__ == 0
+ __real__ result
+ = (absy2 / 2.0f - absy2 * absy2 / 4.0f) * (float) M_LOG10E;
+#else
+ volatile float force_underflow = absy2 * absy2 / 4.0f;
+ __real__ result
+ = (absy2 / 2.0f - force_underflow) * (float) M_LOG10E;
+#endif
+ }
+ else
+ __real__ result = __log1pf (absy2) * ((float) M_LOG10E / 2.0f);
+ }
+ else
+ {
+ float d = __ieee754_hypotf (absx, absy);
+ __real__ result = __ieee754_log10f (d) - scale * M_LOG10_2f;
+ }
- __real__ result = __ieee754_log10f (d) - scale * M_LOG10_2f;
__imag__ result = M_LOG10E * __ieee754_atan2f (__imag__ x, __real__ x);
}
else