#31870 [Opn->Bgs]: rounding negative numbers gives "-0"
| From: | derick@php.net | Date: | Tue, 08 Feb 2005 13:19:28 +0000 |
| Subject: | #31870 [Opn->Bgs]: rounding negative numbers gives "-0" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-73643@lists.php.net to get a copy of this message | ||
ID: 31870
Updated by: derick@php.net
Reported By: amir at foresthc dot com
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: Debian woody
PHP Version: 5.0.3
New Comment:
This is not a discussion forum, and we just use the underlying glibc.
Previous Comments:
------------------------------------------------------------------------
[2005-02-08 14:09:02] amir at foresthc dot com
re-opened to get a reponse.
------------------------------------------------------------------------
[2005-02-07 13:57:34] amir at foresthc dot com
I was under the impression that zero has a unique floating point
representation, and the only problem is with the sign flag.
Also the case at hand is not of "any mathematical operations" but of
call to a mathematical function, and I am assuming there is one common
piece of internal code that round() / number_format() / *printf() all
use.
Obviously having no familiarity with PHP's internal code my assumptions
could be completely incorrect.
------------------------------------------------------------------------
[2005-02-07 13:41:29] derick@php.net
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
Thank you for your interest in PHP.
.
------------------------------------------------------------------------
[2005-02-07 13:08:49] amir at foresthc dot com
Description:
------------
When rounding real negative numbers that should round to zero, the
result is -0 (minus zero). This isn't a critical bug, but it's a
nusanse hunting these down in places were the output reaches the user.
Reproduce code:
---------------
echo round(-0.1);
Expected result:
----------------
0
Actual result:
--------------
-0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31870&edit=1