aboutsummaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-10-25 14:58:12 -0700
committerRichard Henderson <rth@gcc.gnu.org>2002-10-25 14:58:12 -0700
commitcd60b4b8e7d54de00a2d3a5764ebb1c674fcc889 (patch)
treee02de76ba121265c45f6e6dd319c376578c004e8 /gcc/real.c
parent06bd49b10b07b3ab25a21f5fb9f56e2fbd313682 (diff)
downloadgcc-cd60b4b8e7d54de00a2d3a5764ebb1c674fcc889.zip
gcc-cd60b4b8e7d54de00a2d3a5764ebb1c674fcc889.tar.gz
gcc-cd60b4b8e7d54de00a2d3a5764ebb1c674fcc889.tar.bz2
real.c (real_to_decimal): If the >1 tens reduction loop results in a negative exponent...
* real.c (real_to_decimal): If the >1 tens reduction loop results in a negative exponent, fall into the <1 pten computation. From-SVN: r58538
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/gcc/real.c b/gcc/real.c
index a2c9d8a..c3cb719 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1552,20 +1552,28 @@ real_to_decimal (str, r_orig, buf_size, digits, crop_trailing_zeros)
/* Find power of 10. Do this by dividing out 10**2**M when
this is larger than the current remainder. Fill PTEN with
the power of 10 that we compute. */
- m = floor_log2 ((int)(r.exp * M_LOG10_2)) + 1;
- do
+ if (r.exp > 0)
{
- const REAL_VALUE_TYPE *ptentwo = ten_to_ptwo (m);
- if (do_compare (&u, ptentwo, 0) >= 0)
+ m = floor_log2 ((int)(r.exp * M_LOG10_2)) + 1;
+ do
{
- do_divide (&u, &u, ptentwo);
- do_multiply (&pten, &pten, ptentwo);
- dec_exp += 1 << m;
+ const REAL_VALUE_TYPE *ptentwo = ten_to_ptwo (m);
+ if (do_compare (&u, ptentwo, 0) >= 0)
+ {
+ do_divide (&u, &u, ptentwo);
+ do_multiply (&pten, &pten, ptentwo);
+ dec_exp += 1 << m;
+ }
}
+ while (--m >= 0);
}
- while (--m >= 0);
+ else
+ /* We managed to divide off enough tens in the above reduction
+ loop that we've now got a negative exponent. Fall into the
+ less-than-one code to compute the proper value for PTEN. */
+ cmp_one = -1;
}
- else if (cmp_one < 0)
+ if (cmp_one < 0)
{
int m;