#31870 [Bgs]: rounding negative numbers gives "-0"
| From: | amir at foresthc dot com | Date: | Mon, 07 Feb 2005 12:57:35 +0000 |
| Subject: | #31870 [Bgs]: rounding negative numbers gives "-0" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-73596@lists.php.net to get a copy of this message | ||
ID: 31870
User updated by: amir at foresthc dot com
Reported By: amir at foresthc dot com
Status: Bogus
Bug Type: *General Issues
Operating System: Debian woody
PHP Version: 5.0.3
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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