J3/04-298 Date: 4-May-2004 To: J3 From: JOR/interp/Stan Whitlock Subj: F95 interpretation #000004 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 may 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. NOTE: The NO votes in 00-254 were concerned that IEEE Infinities are not model numbers and are therefore not valid results for MINVAL and MAXVAL. The IEEE 754 standard is neither integrated into nor required by Fortran 95. However concessions were made to allow some IEEE exceptional values to be used by standard-conforming processors, like limited support for -0.0. Fortran 2003 uses the same words in MAXVAL and MINVAL as in Fortran 95. EDITS: None. SUBMITTED BY: Larry Rolison HISTORY: 97-240 m143 submitted 00-160r2 m153 Passed 7-5 00-254 m154 Failed J3 letter ballot 04-298 m168 Submitted for J3 meeting vote