------- Comment #5 from sgk at troutmask dot apl dot washington dot edu 2009-01-13 19:43 ------- Subject: Re: New: Diagnose and treat (-2.0)**2.0 properly
On Tue, Jan 13, 2009 at 11:08:40AM -0000, burnus at gcc dot gnu dot org wrote: > > Fortran 2003 in the second sentence of the second paragraph of "7.1.8 > Evaluation of Operations": > > "Raising a negative-valued primary of type real to a real power is > prohibitted." > > The question is whether one needs to reject it completely or only with > -std=f95. Steve (see thread) thinks the constant folding gets it wrong > (-> gives "4.0"). For constant folding, it will be rejected because it can be detected at compile time. > Current results: > - Runtime and compile time evaluation (ifort, gfortran, g95): > -2.0**2.0 = 4.0 > -2.0**1.9 = NaN I believe you're missing ( ) around -2.0 because ** has higher precedence than unary minus. > - Mathematica: > -2^2 = 4, -2.0^2.0 = -4.0 > 2.0^1.9 = -3.73213 Try putting ( ) around -2 in the above. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38823