summaryrefslogtreecommitdiff
path: root/math/s_clog10f.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-07-09 11:06:34 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-07-09 11:06:34 +0000
commit638a572eb0d9af9588bf79e14badc1efefe59d99 (patch)
tree4e519d885a916df57a231f058bafe1bc212b1f0f /math/s_clog10f.c
parentad41a87fe0777b1500df48609307f8d9d906dfb9 (diff)
Fix clog, clog10 spurious underflow exceptions (bug 14337).
Diffstat (limited to 'math/s_clog10f.c')
-rw-r--r--math/s_clog10f.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/math/s_clog10f.c b/math/s_clog10f.c
index 11bb0bb9ad..5a0c370de5 100644
--- a/math/s_clog10f.c
+++ b/math/s_clog10f.c
@@ -43,25 +43,30 @@ __clog10f (__complex__ float x)
else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
+ float absx = fabsf (__real__ x), absy = fabsf (__imag__ x);
float d;
int scale = 0;
- if (fabsf (__real__ x) > FLT_MAX / 2.0f
- || fabsf (__imag__ x) > FLT_MAX / 2.0f)
+ if (absx > FLT_MAX / 2.0f)
{
scale = -1;
- __real__ x = __scalbnf (__real__ x, scale);
- __imag__ x = __scalbnf (__imag__ x, scale);
+ absx = __scalbnf (absx, scale);
+ absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f);
}
- else if (fabsf (__real__ x) < FLT_MIN
- && fabsf (__imag__ x) < FLT_MIN)
+ 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;
- __real__ x = __scalbnf (__real__ x, scale);
- __imag__ x = __scalbnf (__imag__ x, scale);
+ absx = __scalbnf (absx, scale);
+ absy = __scalbnf (absy, scale);
}
- d = __ieee754_hypotf (__real__ x, __imag__ x);
+ d = __ieee754_hypotf (absx, absy);
__real__ result = __ieee754_log10f (d) - scale * M_LOG10_2f;
__imag__ result = M_LOG10E * __ieee754_atan2f (__imag__ x, __real__ x);