On Wed, Nov 13, 2024 at 05:33:20PM +0100, Thomas Koenig wrote: > Am 13.11.24 um 15:55 schrieb Toon Moene: > > > > Since the Fortran 95 Standard it does (in the current Standard: 7.4.3.2 > > Real type): > > > > The real type includes a zero value. Processors that distinguish between > > positive and negative zeros shall treat them as mathematically > > equivalent > > • in all intrinsic relational operations, and > > • as actual arguments to intrinsic procedures other than those for which > > it is explicitly specified that negative zero is distinguished. > > > > [Note that "processor" in Fortran standardese means everything > > (combined) from the compiler down to the actual hardware]. > > > > So we have to comb through the Standard to see where bullet 2 applies ... > > I looked through the current standard, and the only mention of positive > and negative zero I could find were in the IEEE intrinsics. > > So, I think we could ignore signed zeros (from the Fortran standard > perspective) > > - for complex arithmetic, always > - for real arithmetic, if none of the IEEE modules is USEd >
Possibly ending up on the wrong Riemann sheet seems like a good idea to me. If you're going to revisit complex multication and division, then I believe the -fcx-fortran-rules option should be removed. It states Complex multiplication and division follow Fortran rules. There are no special rules for Fortran. The rules for Fortran are (24-007r1.pdf, p162) The two operands of numeric intrinsic binary operations may be of different numeric types or different kind type parameters. Except for a value of type real or complex raised to an integer power, if the operands have different types or kind type parameters, the effect is as if each operand that differs in type or kind type parameter from those of the result is converted to the type and kind type parameter of the result before the operation is performed. So, (1) r*z = (r+I0)*(x+Iy), which is gfortran's current behavior. Once the interpretation of a numeric intrinsic operation is established, the processor may evaluate any mathematically equivalent expression, provided that the integrity of parentheses is not violated. (There are implicit parentheses above, but let's let that go.) (2) r*z = r*x + Ir*y This appears to be mathematically equivalent, except they are not. +-0 and +-inf are fundamental to the foundations of calculus and branch cuts in complex plane. gfortran does (1) by default. Users can get (2) if they use -ffast-math, -Ofast or -fno-cx-fortran-rules. J3 threw a red herring and cop out into the interpretation by making a statement that IEEE754 does consider complex number. Of course, it would not! IEEE754 deals with mapping real numbers to a finite set of floating point numbers. J3 should have considered Annex G, "IEC 60559-compatible complex arithmetic" from C23; specially, G.5.1 "Multiplicative operators". -- Steve