fjhenigman@watcgl.waterloo.edu (Frank J. Henigman) (05/24/89)
The man page for atan2 explicitly states that atan2(0, 0) = 0. However the following program outputs NaN. #include <math.h> main() { printf("%f\n", atan2(0.0, 0.0)); } Which is wrong: the man page or atan2? (I tried both libm and libm43 on a Personal Iris and a 4D.) -- fjhenigman@watcgl.uwaterloo.ca Computer Graphics Lab fjhenigman@watcgl.waterloo.edu Frank J. Henigman University of Waterloo ...!watmath!watcgl!fjhenigman Waterloo, Ontario, Canada
blbates@AERO4.LARC.NASA.GOV ("Brent L. Bates TAD/TAB ms294 x42854") (05/24/89)
atan2 must be wrong. The only invalid input would be NaN or infinity. -- Brent L. Bates NASA-Langley Research Center M.S. 294 Hampton, Virginia 23665-5225 (804) 864-2854 E-mail: blbates@aero4.larc.nasa.gov or blbates@aero2.larc.nasa.gov
davea@quasar.wpd.sgi.com (David B. Anderson) (05/24/89)
In article <9868@watcgl.waterloo.edu>, fjhenigman@watcgl.waterloo.edu (Frank J. Henigman) writes: > > The man page for atan2 explicitly states that atan2(0, 0) = 0. > However the following program outputs NaN. [ example deleted] > Which is wrong: the man page or atan2? > (I tried both libm and libm43 on a Personal Iris and a 4D.) > -- > fjhenigman@watcgl.uwaterloo.ca Computer Graphics Lab > fjhenigman@watcgl.waterloo.edu Frank J. Henigman University of Waterloo > ...!watmath!watcgl!fjhenigman Waterloo, Ontario, Canada The MIPS-supplied libm atan2(0.0,0.0) produces the default quiet NaN. errno is not set. For release 3.2 the man page has been changed to say that a) libm atan2(0.0,0.0) produces the default quiet NaN. b) libm43 (the Berkeley libm) atan2(0.0,0.0) produces 0.0. This is the atan2 the discussion applies to. The SVID specifies a third behavior: atan2(0.0,0.0) returns 0.0 while setting errno to EDOM and emitting a message on standard error. ANSI C May 1988 draft says about atan2 (section 4.5.2.4): ``A domain error may occur if both arguments are zero.'' Note that on a domain error, the function returns an implementation-defined value by section 4.5.1. Anyone who has strong opinions about libm's behavior should send me e-mail. Regards, [ David B. Anderson Silicon Graphics (415) 964-1459 x3060 ] [ USENET: {decwrl!,hplabs!sun!}sgi!davea Internet: davea@sgi.com ]