Interpretation 004
To: J3
From: John Reid
Date: April 17, 2000
Subject: Interpretation 004
Here are the drafts for the ANSWER and EDITS sections of Interpretation 004.
Malcolm disagrees with me on this one and we have had to "agree to disagree". He objects to "should be", but
would not object to "may be" (but still thinks it is the wrong thing to do).
I have asked a few of my mathematical friends what they think and those that are familiar with the IEEE
standard and the thinking behind it agree with me that asking for MAXVAL for a zero-size array is just like
asking for -1.0/0.0 and should return -inf.
NUMBER: 000004
TITLE: Value returned by MAXVAL/MINVAL
KEYWORDS: MAXVAL, MINVAL
DEFECT TYPE: Interpretation
STATUS: J3 consideration in progress
QUESTION:
The Result Value section of the MAXVAL intrinsic function description uses the phrasing:
or has the value of the negative number of the largest magnitude supported by the processor for numbers of
the type and kind type parameter of ARRAY if ARRAY has size zero
This phrasing has generated at least the two following views on the return value:
* If the machine supports the IEEE standard then the implementation should return -inf.
* For portability, the implementation should return -HUGE(ARRAY).
These views lead to the following questions:
1. Is the intent of the standard to describe the result in terms of machine values rather than model values?
2. If the answer to 1 is "yes", how are programmers expected to use this intrinsic function portably?
ANSWER:
1. Yes. Processors may support values that are not present in the model of 13.7.1. IEEE -inf is an example of
such a number and this should be returned on a machine that supports the IEEE standard. If the negative
number of the largest magnitude in the model had been intended, the model would have been mentioned as, for
example, in the definition of HUGE (13.14.39).
2. A simple example of its use is to test whether a set of numbers SET1 has a value greater than any value in
the set SET2. Consider the expression MAXVAL (SET1) > MAXVAL (SET2). If SET1 is empty and SET2 is not,
this value is correctly false even if all of the values are outside the model with values less than -HUGE (SET1).
It may be helpful to consider how MAXVAL might be coded for an array of rank one on an IEEE computer.
The following code is suitable.
MAXVAL = IEEE_VALUE ( 1.0, IEEE_NEGATIVE_INF)
DO I = 1, SIZE (ARRAY)
MAXVAL = MAX (MAXVAL, ARRAY(I))
END DO
All of the reduction functions (e.g., MAXVAL, SUM) return values when the arguments are zero-sized arrays
that may be the same as the values returned for some non-zero-sized arguments.
EDITS: None.
SUBMITTED BY: Larry Rolison
HISTORY: 97-240 m143 submitted
00-160r1 m153 Proposed response
[End of J3 / 00-160r1]