J3/05-193r1 Date: 9 Aug 2005 To: J3 From: Stan Whitlock Subject: Precision of operation NUMBER: F03/0066 TITLE: precision of operation KEYWORDS: precision, operation DEFECT TYPE: Interpretation STATUS: For consideration QUESTION: Given REAL X X = ... some value ... IF( (X+3.0) .EQ. 3.0 )... may the X+3.0 be computed with more range and/or precision than that of REAL? In other words, is PRECISION(X) .EQ. PRECISION(X+3.0) always true; or is PRECISION(X) .LT. PRECISION(X+3.0) sometimes true? References are to J3/04-007. 2.4.1.1 Intrinsic type has "The kind type parameter indicates ... the decimal precision and exponent range for the real and complex types, ..." 7.1.4.2 Type, type parameters, and shape of the result of an operation has in (4) "For an expression x1 op x2 where op is a numeric intrinsic binary operator with both operands of the same type and kind type parameters, ..., the kind type parameter of the expression is identical to that of each operand." Since X and 3.0 are the same type and have the same kind type parameters, 7.1.4.2 (4) appears to require the X+3.0 have just the range and precision of REAL; no more, no less (otherwise, the precision is not identical). But, several members of the J3 email list have said that the "+" may be done with more precision; using either 1.4(6) or 7.1.8.3 as the reason. Perhaps something alone the lines of "The values of floating operands and of the results of floating expressions may be represented in greater precision and range than that required by the kind type parameter; the kind type parameter is not changed thereby." should be added to 7.1.4.2(4). QUESTION: Is PRECISION(X) .EQ. PRECISION(X+3.0) always true? ANSWER: Yes, that is the definition of PRECISION. The PRECISION intrinsic has nothing to do with the precision in which the computation X+3.0 is computed. 7.1.4.2 (4) only describes the precision of the end result of the computation. The weasel words in 1.4 (6) allow the processor to compute this expression in higher precision than REAL. EDITS: None SUBMITTED BY: Fred Tydeman HISTORY: 05-193 m173 Submitted 05-193r1 m173 Proposed answer