php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78660 Round works different on PHP 7.4
Submitted: 2019-10-10 11:48 UTC Modified: 2019-10-11 15:12 UTC
From: s dot sayakci at shopware dot com Assigned: nikic (profile)
Status: Closed Package: *Math Functions
PHP Version: 7.4.0RC3 OS: Linux (NixOs)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: s dot sayakci at shopware dot com
New email:
PHP Version: OS:

 

 [2019-10-10 11:48 UTC] s dot sayakci at shopware dot com
Description:
------------
We did found that round does work in different way in PHP 7.4 so our Tests are currently failing. I checked the https://www.php.net/manual/en/migration74.incompatible.php and could not found any change on round function.
When you pass -1 as float to round we got 0 until PHP 7.4, now we get also -1.
Is this change intended? Cause its not mentioned.
3v4l: https://3v4l.org/eLXVb

Test script:
---------------
var_dump((string) round((float) "-0", 2));


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-10 11:56 UTC] s dot sayakci at shopware dot com
I guess it's related to https://github.com/php/php-src/commit/0c0659dc50dc17b267072f95c6e1ebddcc91e82d#diff-b3ab69987aa0c09f941f1374aaf483c2R132
 [2019-10-11 09:15 UTC] jhdxr@php.net
The following pull request has been associated:

Patch Name: fix bug #78660 rounding negative zero
On GitHub:  https://github.com/php/php-src/pull/4813
Patch:      https://github.com/php/php-src/pull/4813.patch
 [2019-10-11 15:12 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2019-10-11 15:12 UTC] nikic@php.net
Upgrading note added in https://github.com/php/php-src/commit/aa10e208303e8a36f543b2c0afbc15f1ca980410.

As cmb pointed out on the PR, the new behavior complies with POSIX, which explicitly states that round(-0.0) must be -0.0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC