J3/04-216 Date: 2004-01-14 To: J3 From: Walt Brainerd Subject: Negative zero Date: 2004-01-07 at 17:17:03 Request number: Pub-109 Name: James Giles E_mail: jamesgiles@att.net ======================================================= Number: Title: Negative zero Submitted by: J3 Status: For Consideration References: FCD §4.4.2 Basic Functionality: The constraint in §4.4.2 of the standard requires behavior that is inconsistent with common expectations. If all intrinsic functions are prohibited from recognizing the difference between positive and negative zero, then the following results are required (all of which, to meet common expectations should be different): AIMAG((0.0, -0.0)) -> 0.0 CMPLX(-0.0, -0.0) -> (0.0, 0.0) CONJG((0.0, -0.0)) -> (0.0, -0.0) ! DBLE(-0.0) -> 0.0d0 DPROD(0.0, -0.0) -> 0.0d0 MAX(-1.0, -0.0) -> 0.0 MIN(1.0, -0.0) -> 0.0 REAL(-0.0d0) -> 0.0 ASIN(-0.0) -> 0.0 ATAN(-0.0) -> 0.0 SIN(-0.0) -> 0.0 SINH(-0.0) -> 0.0 TAN(-0.0) -> 0.0 TANH(-0.0) -> 0.0 TRANSFER(-0.0, 0.0) -> 0.0 MERGE(-0.0, 1.0, .true.) -> 0.0 There are other cases that are also arguably controlled by the existing constraint (in which -0.0 appears as a value inside an array argument, for example). None of the above results meet common expectations. Rationale: Many existing implementations already ignore this constraint. To force them to conform would decrease their quality of implementation. Of those intrinsic functions relevant to this constraint, all should distinguish positive from negative zero, rather than being prohibited from doing so. Estimated Impact: Little. Simply eliminating the constraint will require no changes to existing implementations. Existing Fortran programs already have to accomodate negative zeros as results from implementations that violate the constraint. In future, people will more often want behavior consistent with usual practice among the rest of the numerical software community. Eliminating the constraint will permit implementations to accomodate this trend. Detailed Specification: Referring to the FCD: Delete lines 38:3-4 Change line 38:5 to: (2) as the scalar-numeric-expr in an arithmetic IF. History: Submitted as Pub-109