|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70568 atan2 returns NAN
Submitted: 2015-09-24 08:59 UTC Modified: 2018-06-24 04:22 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: goodnickoff at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Math related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
6 + 9 = ?
Subscribe to this entry?

 [2015-09-24 08:59 UTC] goodnickoff at gmail dot com
If both parameters are INF or -INF sometimes atan2 function returns NAN but sometimes -2.3561944901923.

results on different versions of PHP and OS:

PHP 5.5.27 (cli) (built: Jul 23 2015 00:21:59) 
macos 64bit

PHP 5.4.39 (cli) (built: Mar 19 2015 22:16:19) 
Thread Safety enabled
Windows NT 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586 x86

PHP Version 5.5.21 Build Date Jan 21 2015 14:38:49
Thread Safety enabled
Windows NT CZC4433C6H-HP 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) AMD64

PHP 5.6.11 (cli) (built: Jul  9 2015 20:55:40) x86
Thread Safety enabled
Windows NT 10.0; Win64; x64 (Build 10240)

Test script:
php -r 'echo atan2(-INF, -INF);'

Expected result:

Actual result:


php-5.6.13-atan2.diff (last revision 2015-09-30 22:13 UTC by n13 at inbox dot ru)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-24 09:24 UTC] goodnickoff at gmail dot com
-Operating System: All +Operating System: * -PHP Version: 5.6.13 +PHP Version: *
 [2015-09-24 09:24 UTC] goodnickoff at gmail dot com
Occurs on different versions of PHP
 [2015-09-24 12:05 UTC] goodnickoff at gmail dot com
This happens on 32 bit php installed on 64 bit OS.
 [2015-09-30 20:51 UTC] n13 at inbox dot ru
GCC 4.8.1 from MinGW and VS Community 2013 gives the same result
Output from gcc 4.9.2 (Debian)
 [2018-03-17 17:47 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-03-17 17:47 UTC]
This issue appears to be indeed related to the C compiler or the
runtime environment.  I'm not convinced that we should apply a
workaround similar to the one in the supplied patch, especially,
since the issue appears to have been resolved for MSVC 14 and 15
at least.

Can anybody else reproduce the described misbehavior with
supported PHP versions on contemporary compilers/runtimes?
 [2018-06-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 04:01:27 2023 UTC