Xref: utzoo comp.compilers:1459 comp.lang.fortran:4021 Path: utzoo!attcan!uunet!samsung!usc!apple!olivea!mintaka!spdcc!esegue!compilers-sender From: bsy+@CS.CMU.EDU (Bennet Yee) Newsgroups: comp.compilers,comp.lang.fortran Subject: Re: IEEE 754 vs Fortran arithmetic Keywords: Fortran, arithmetic Message-ID: <1990Oct28.030338.29498@cs.cmu.edu> Date: 28 Oct 90 03:03:38 GMT References: <9010230628.AA22160@admin.ogi.edu> <2408@charon.cwi.nl> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: Bennet Yee Organization: Cranberry Melon, School of Cucumber Science Lines: 39 Approved: compilers@esegue.segue.boston.ma.us In article <2408@charon.cwi.nl>, dik@cwi.nl (Dik T. Winter) writes: |> ... We are working on the |> standardization of elementary mathematical functions in Ada. The current |> status is that the basic package of functions like SINE, COSINE etc. is |> very near to standardization. One of the functions included is: |> ARCTAN(Y, X) |> which returns the arctangent of Y/X. (Fortran users will recognize the |> ATAN2 function.) The specification tells us that the result is the range |> from -PI to +PI (approximately). The problem is, what is the result of |> ARCTAN(Y, zero). Does it depend on the sign of zero? Offhand I do not |> know what the Fortran standard tells us. Is there something I'm missing? As far as I knew, ARCTAN(Y,0) = pi/2 if Y > 0 -pi/2 if Y < 0 regardless of the sign on the zero. If Y = 0, then it's not well defined. (I don't recall what 754 has to say about this case.) Perhaps the problem occurs when you compute ARCTAN(0,X) when X<0? Assuming that you want the range to be from -pi to +pi, you can argue that the answer should depend on the sign on 0: if the zero is negative, then use -pi; otherwise use pi. In some sense, this isn't really a problem with signed zeros but rather more a problem with the discontinuity in the definition of the inverse tangent.... Bennet S. Yee, +1 412 268-7571 School of Cucumber Science, Cranberry Melon, Pittsburgh, PA 15213-3890 Internet: bsy+@cs.cmu.edu Uunet: ...!seismo!cs.cmu.edu!bsy+ Csnet: bsy+%cs.cmu.edu@relay.cs.net Bitnet: bsy+%cs.cmu.edu@cmuccvma -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.