aboutsummaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@redhat.com>2004-02-08 20:00:30 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2004-02-08 20:00:30 +0000
commit7c476bdec6f46df5da4984a0a0cdff2ce4f00ff1 (patch)
tree552097bec08beca4ae6f4b3379ee0a4735807d29 /gcc/real.c
parent56ae04afa2cabf3efabc991cfb765cf5fe1b547c (diff)
downloadgcc-7c476bdec6f46df5da4984a0a0cdff2ce4f00ff1.zip
gcc-7c476bdec6f46df5da4984a0a0cdff2ce4f00ff1.tar.gz
gcc-7c476bdec6f46df5da4984a0a0cdff2ce4f00ff1.tar.bz2
real.c (encode_ibm_extended): Normalize the input value before converting it to a double.
* real.c (encode_ibm_extended): Normalize the input value before converting it to a double. Handle the case where a normal value rounds to infinity. From-SVN: r77498
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/real.c b/gcc/real.c
index cd27d3e..474da31 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -3230,19 +3230,24 @@ static void
encode_ibm_extended (const struct real_format *fmt, long *buf,
const REAL_VALUE_TYPE *r)
{
- REAL_VALUE_TYPE u, v;
+ REAL_VALUE_TYPE u, normr, v;
const struct real_format *base_fmt;
base_fmt = fmt->qnan_msb_set ? &ieee_double_format : &mips_double_format;
+ /* Renormlize R before doing any arithmetic on it. */
+ normr = *r;
+ if (normr.class == rvc_normal)
+ normalize (&normr);
+
/* u = IEEE double precision portion of significand. */
- u = *r;
+ u = normr;
round_for_format (base_fmt, &u);
encode_ieee_double (base_fmt, &buf[0], &u);
- if (r->class == rvc_normal)
+ if (u.class == rvc_normal)
{
- do_add (&v, r, &u, 1);
+ do_add (&v, &normr, &u, 1);
round_for_format (base_fmt, &v);
encode_ieee_double (base_fmt, &buf[2], &v);
}