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
This commit is contained in:
parent
70a76cbca8
commit
35fd722b61
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user