09-222 To: J3 Members From: Stan Whitlock Subject: J3 Fortran interp F03/0039 Date: 2009 February 23 Section 1. Instructions ---------- Section 2 is the answer to the F2003 interp F03/0039. Section 3 is the proposed edit to fix the problem raised in F03/0039 in F2008. Section 2. F2003 interp ---------------------------------------------------------------------- NUMBER: F03/0039 TITLE: HYPOT() KEYWORDS: IEEE-754, hypot() DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: What is HYPOT(NaN,infinity)? HYPOT(NaN,finite)? HYPOT(X,Y) when X and/or Y is an infinity (even if the other is a NaN) shall be +infinity. Reason: hypot(), when one of the arguments is an infinity, is +infinity independent of the value of the other argument. So, if the NaN argument is replaced by zero, any finite number, or any infinity, hypot(infinity,NaN) is still infinity. HYPOT(X,Y) when X and/or Y is a NaN (and neither is infinite) shall be a NaN, and should one of the NaN arguments. ANSWER: The HYPOT example in note 14.17 illustrates the use of the features of this section to provide reliable software that is fast in the uncomplicated case. We did not consider what would happen if one of the arguments is a NaN and have therefore edited the text slightly. DISCUSSION: In fact, if either X or Y is a NaN, the first executable statement will set HYPOT to a NaN without signaling an exception. The slower code in the IF construct will therefore not be executed and a NaN will be returned, which is consistent with the way NaNs are handled by intrinsic operators, see paragraph 3 of section 6.2 of the IEEE International Standard. EDITS: Page and line numbers refer to 04-007. [page 389]. Subclause 14.11, Note 14.17, final paragraph, line 2. Before "exception" add "overflow or underflow". SUBMITTED BY: Fred Tydeman HISTORY: 05-118 m171 F03/0039 submitted 05-118r3 m171 Passed by J3 meeting 05-170 m172 Passed J3 letter ballot #11 N1622 m172 Failed WG5 ballot N1629 09-222 m188 Revised answer ---------------------------------------------------------------------- Section 3. F2008 fix --------- Fix the problem reported in F2003 interp F03/0039 in F2008 as follows: In 09-007, subclause 14.12 "Examples", Note 14.17, final paragraph, line 2 [page 431]: Before "exception" add "overflow or underflow".