php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42477 round() returns negative zero
Submitted: 2007-08-29 19:57 UTC Modified: 2007-08-29 20:24 UTC
From: koen at genericmedia dot nl Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.3 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: koen at genericmedia dot nl
New email:
PHP Version: OS:

 

 [2007-08-29 19:57 UTC] koen at genericmedia dot nl
Description:
------------
When rounding a small negative number, the function returns a negative zero. I suspect this has something to do with computing precision, so I suppose that the reason is not really a bug. I've seen the bug report at #31870 and I understand the answer. Strange thing is however that prior to 5.2.3 the result actually was float(0).

Reproduce code:
---------------
<?php
  var_dump( round(-0.26) );
?>

Expected result:
----------------
float(0)

Actual result:
--------------
PHP 4.3.10:
float(0)

PHP 4.4.6:
float(0)

PHP 5.1.6:
float(0)

PHP 5.2.3:
float(-0)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-29 20:24 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 11:01:32 2024 UTC