Bug #78627 [Opn]: acos(1) is giving NAN instead of 0
| From: | cmb@php.net | Date: | Thu, 03 Oct 2019 10:35:16 +0000 |
| Subject: | Bug #78627 [Opn]: acos(1) is giving NAN instead of 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-223016@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78627&edit=1
ID: 78627
Updated by: cmb@php.net
Reported by: me at gmorel dot io
Summary: acos(1) is giving NAN instead of 0
Status: Open
Type: Bug
Package: *Math Functions
Operating System: Linux Debian
PHP Version: 7.2.23
Block user comment: N
Private report: N
New Comment:
Cannot reproduce: <https://3v4l.org/LTLAg>.
Previous Comments:
------------------------------------------------------------------------
[2019-10-03 10:10:45] me at gmorel dot io
Description:
------------
---
From manual page: https://php.net/function.acos
---
Hi,
Thanks for all your work.
Since the PHP 7.2.20 the acos function seems to have a regression. We have first isolated the bug in
7.2.23
In the case of
$dist = sin(deg2rad(45.9007)) * sin(deg2rad(45.9007)) + cos(deg2rad(45.9007)) *
cos(deg2rad(45.9007));
Before acos($dist) => 0
After acos($dist) => NAN
uname -a
Linux 609379a2965b 5.0.0-29-generic #31-Ubuntu SMP Thu Sep 12 13:05:32 UTC 2019 x86_64 GNU/Linux
php -v
PHP 7.2.23 (cli) (built: Sep 26 2019 23:37:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.23, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
âKeep up the good work
â
Test script:
---------------
PHP 7.2.18 (sorry they didn't have 7.2.19)
http://sandbox.onlinephpfunctions.com/code/e59e94fa7aee04d67cbacf2990773c1658e4d1c2
It seems to have no issue in 7.3.5
But it appears also in 7.3.10 (cli)
Expected result:
----------------
$dist = sin(deg2rad(45.9007)) * sin(deg2rad(45.9007)) + cos(deg2rad(45.9007)) *
cos(deg2rad(45.9007));
var_dump(acos($dist)); // float(0)
Actual result:
--------------
$dist = sin(deg2rad(45.9007)) * sin(deg2rad(45.9007)) + cos(deg2rad(45.9007)) *
cos(deg2rad(45.9007));
var_dump(acos($dist)); // double(NAN)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78627&edit=1