25 Oct 90 00:46:27 GMT

Related articles |
---|

IEEE 754 vs Fortran arithmetic robertsj@admin.ogi.edu (John Roberts) (1990-10-22) |

Re: IEEE 754 vs Fortran arithmetic burley@world.std.com (1990-10-24) |

Re: IEEE 754 vs Fortran arithmetic henry@zoo.toronto.edu (1990-10-24) |

Re: IEEE 754 vs Fortran arithmetic tim@ksr.com (Tim Peters) (1990-10-24) |

Re: IEEE 754 vs Fortran arithmetic dik@cwi.nl (1990-10-25) |

Re: IEEE 754 vs Fortran arithmetic wsb@eng.Sun.COM (1990-10-25) |

Re: IEEE 754 vs Fortran arithmetic eggert@twinsun.com (1990-10-25) |

Re: IEEE 754 vs Fortran arithmetic wsb@eng.Sun.COM (1990-10-25) |

Re: IEEE 754 vs Fortran arithmetic sjc@key.COM (1990-10-26) |

Re: IEEE 754 vs Fortran arithmetic diamond@tkov50.enet.dec.com (1990-10-15) |

Re: IEEE 754 vs Fortran arithmetic tim@ksr.com (Tim Peters) (1990-10-27) |

Re: IEEE 754 vs Fortran arithmetic bsy+@CS.CMU.EDU (Bennet Yee) (1990-10-28) |

[1 later articles] |

Newsgroups: | comp.compilers,comp.lang.fortran |

From: | wsb@eng.Sun.COM (Walt Brainerd) |

Followup-To: | comp.lang.fortran |

Keywords: | Fortran |

Organization: | Compilers Central |

References: | <9010230628.AA22160@admin.ogi.edu> <BURLEY.90Oct24025053@world.std.com> |

Date: | 25 Oct 90 00:46:27 GMT |

In article <BURLEY.90Oct24025053@world.std.com>, burley@world.std.com (James C Burley) writes:

*> *

*> I don't know any references, but I do know we ran into this problem*

*> implementing Fortran on a machine using an IEEE 754 math chip:*

*> *

*> REAL R(...)*

*> DATA R/0.5,1.5,2.5,3.5,.../*

*> DO I=1,...*

*> PRINT *,NINT(R)*

*> END DO*

*> END*

*> *

*> Fortran specifies that the following values must be output:*

*> *

*> 1, 2, 3, 4,...*

We have had this discussion before some here, but to be a bit nit-picking,

"Fortran" (i.e., the standard) does not specify such things, as it

does not even specify what + means. It certainly does encourage

such things and a vendor must be prepared to answer to the customer,

but not worry about strict standard conformace in this area.

*> *

*> However, the IEEE 754 defines nearest-integer so that using its function*

*> instead of Fortran's definition of NINT produces:*

*> *

*> 0, 2, 2, 4,...*

*> *

*> Also, Fortran specifically prohibits zero from being negative (or being*

*> significantly negative*

The appendix (not a legal part of the standard) says:

"A processor must not consider a negative zero to be different

from a positive zero."

I would take this as a SUGGESTION to make 0 and I-I compare true,

however the result of the subtraction is represented.

The standard (13.5.9) does say that a "negative signed zero"

must not be produced when doing numeric output into a formatted record.

So, from the point of view of the standard, printing 4-4 as 7 is OK,

but printing it as -0 (with say an I2 format) is not!

It's just a matter of who you run to if something doesn't work

the way you think it should.

--

Walt Brainerd Sun Microsystems, Inc.

wsb@eng.sun.com MS MTV 5-40

Mountain View, CA 94043

415/336-5991

--

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.