Edit report at https://bugs.php.net/bug.php?id=62845&edit=1

 ID:                 62845
 Updated by:         ras...@php.net
 Reported by:        bradley dot lee80 at googlemail dot com
 Summary:            round returns -0
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Math related
 Operating System:   Linux (Ubuntu)
 PHP Version:        5.3.16
 Block user comment: N
 Private report:     N

 New Comment:

Computers use a standard described in IEEE-754 to handle floating point values. 
IEEE-754 uses -0 to describe values that approach 0 from a negative value. You 
will see the same thing in any language that uses the computer's built-in 
floating point mechanism. C, Python, Ruby, Perl, etc. For example in Python:

>>> round(-0.1)
-0.0

You can read more about it at:

http://en.wikipedia.org/wiki/Signed_zero


Previous Comments:
------------------------------------------------------------------------
[2012-08-17 12:22:16] ni...@php.net

Could you elaborate on why this would not be the expected behavior?

Also zero and negative zero are defined to compare equal, so I'm not sure 
whether this makes any difference in practice.

------------------------------------------------------------------------
[2012-08-17 09:30:23] bradley dot lee80 at googlemail dot com

Description:
------------
---
>From manual page: 
>http://www.php.net/function.round#refsect1-function.round-description
---

The round function returns -0 if the value is a negative value that should 
round to 0

Test script:
---------------
<?php
        echo round(-0.1);



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62845&edit=1

Reply via email to