09-222r1
To: J3 Members
From: Stan Whitlock
Subject: J3 Fortran interp F03/0039
Date: 2009 May 6
NUMBER: F03/0039
TITLE: HYPOT()
KEYWORDS: IEEE-754, hypot()
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress
QUESTION:
HYPOT is the Fortran function defined in Note 14.17.
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.
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.
To make this explicit, an edkit is mprovided to test for these
conditions.
EDITS:
Page and line numbers refer to 04-007.
[page 389]. Subclause 14.11, Note 14.17, after the comment
"! The processor clears the flags on entry"
insert
" IF (IEEE_IS_NAN (x) .OR. IEEE_IS_NAN (Y)) THEN
HYPOT = SQRT (-1.0)
ENDIF"
[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
09-222r1 m188 Revised again to test for NAN arguments