diff options
author | Jerry DeLisle <jvdelisle@verizon.net> | 2005-07-24 02:24:15 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2005-07-24 02:24:15 +0000 |
commit | 35fd722b61b9a1603c204b0d493b2a56fd058cde (patch) | |
tree | b5c2c10083bd892859507b8b4697dae1b7b318bb | |
parent | 70a76cbca81a7b69373170dc86e0ac7d315c99d6 (diff) | |
download | gcc-35fd722b61b9a1603c204b0d493b2a56fd058cde.zip gcc-35fd722b61b9a1603c204b0d493b2a56fd058cde.tar.gz gcc-35fd722b61b9a1603c204b0d493b2a56fd058cde.tar.bz2 |
write.c (write_float): Revise output of IEEE exceptional values to comply with F95 and F2003 standards.
2005-07-23 Jerry DeLisle <jvdelisle@verizon.net>
* io/write.c (write_float): Revise output of IEEE exceptional
values to comply with F95 and F2003 standards.
From-SVN: r102324
-rw-r--r-- | libgfortran/ChangeLog | 5 | ||||
-rw-r--r-- | libgfortran/io/write.c | 38 |
2 files changed, 39 insertions, 4 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 747ef9e..3e37aac 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2005-07-23 Jerry DeLisle <jvdelisle@verizon.net> + + * io/write.c (write_float): Revise output of IEEE exceptional + values to comply with F95 and F2003 standards. + 2005-07-22 Jerry DeLisle <jvdelisle@verizon.net> PR libfortran/22570 diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 54bf480..a702de1 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -772,6 +772,11 @@ write_float (fnode *f, const char *source, int len) if (res == 0) { nb = f->u.real.w; + + /* If the field width is zero, the processor must select a width + not zero. 4 is chosen to allow output of '-Inf' or '+Inf' */ + + if (nb == 0) nb = 4; p = write_block (nb); if (nb < 3) { @@ -784,18 +789,43 @@ write_float (fnode *f, const char *source, int len) if (res != 0) { if (signbit(n)) - fin = '-'; + { + + /* If the sign is negative and the width is 3, there is + insufficient room to output '-Inf', so output asterisks */ + + if (nb == 3) + { + memset (p, '*',nb); + return; + } + + /* The negative sign is mandatory */ + + fin = '-'; + } else - fin = '+'; + + /* The positive sign is optional, but we output it for + consistency */ + + fin = '+'; if (nb > 8) + + /* We have room, so output 'Infinity' */ + memcpy(p + nb - 8, "Infinity", 8); else + + /* For the case of width equals 8, there is not enough room + for the sign and 'Infinity' so we go with 'Inf' */ + memcpy(p + nb - 3, "Inf", 3); if (nb < 9 && nb > 3) - p[nb - 4] = fin; + p[nb - 4] = fin; /* Put the sign in front of Inf */ else if (nb > 8) - p[nb - 9] = fin; + p[nb - 9] = fin; /* Put the sign in front of Infinity */ } else memcpy(p + nb - 3, "NaN", 3); |