Change 33676 by [EMAIL PROTECTED] on 2008/04/14 14:47:15

        Make atan2(0,0) return undef

Affected files ...

... //depot/perl/pod/perlfunc.pod#596 edit
... //depot/perl/pp.c#627 edit
... //depot/perl/t/op/exp.t#10 edit

Differences ...

==== //depot/perl/pod/perlfunc.pod#596 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod#595~33651~    2008-04-06 07:57:40.000000000 -0700
+++ perl/pod/perlfunc.pod       2008-04-14 07:47:15.000000000 -0700
@@ -492,8 +492,7 @@
 
     sub tan { sin($_[0]) / cos($_[0])  }
 
-Note that atan2(0, 0) is not well-defined, however the Perl
-implmentation returns C<0> for this value.
+Perl returns C<undef> for C<atan(0,0)>.
 
 =item bind SOCKET,NAME
 X<bind>

==== //depot/perl/pp.c#627 (text) ====
Index: perl/pp.c
--- perl/pp.c#626~33618~        2008-03-31 12:48:26.000000000 -0700
+++ perl/pp.c   2008-04-14 07:47:15.000000000 -0700
@@ -2798,7 +2798,10 @@
     dVAR; dSP; dTARGET; tryAMAGICbin(atan2,0);
     {
       dPOPTOPnnrl;
-      SETn(Perl_atan2(left, right));
+      if (left == 0.0 && right == 0.0)
+         SETs(&PL_sv_undef);
+      else
+         SETn(Perl_atan2(left, right));
       RETURN;
     }
 }

==== //depot/perl/t/op/exp.t#10 (xtext) ====
Index: perl/t/op/exp.t
--- perl/t/op/exp.t#9~24388~    2005-05-04 13:50:59.000000000 -0700
+++ perl/t/op/exp.t     2008-04-14 07:47:15.000000000 -0700
@@ -6,7 +6,7 @@
     require './test.pl';
 }
 
-plan tests => 16;
+plan tests => 17;
 
 # compile time evaluation
 
@@ -57,3 +57,7 @@
 # atan2() tests were removed due to differing results from calls to
 # atan2() on various OS's and architectures.  See perlport.pod for
 # more information.
+
+# Just test that atan2(0,0) is undef, because that's implemented
+# from within perl.
+ok(!defined(atan2(0,0)), 'atan2(0,0) returns undef');
End of Patch.

Reply via email to