atan2(0, 0) = ???
David B. Anderson
davea at quasar.wpd.sgi.com
Thu May 25 02:17:06 AEST 1989
In article <9868 at watcgl.waterloo.edu>, fjhenigman at 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 at watcgl.uwaterloo.ca Computer Graphics Lab
> fjhenigman at 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 at sgi.com ]
More information about the Comp.sys.sgi
mailing list