Bug #67746 [Opn->Nab]: Bugs in built-in functions
| From: | aharvey@php.net | Date: | Tue, 05 Aug 2014 19:14:35 +0000 |
| Subject: | Bug #67746 [Opn->Nab]: Bugs in built-in functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186990@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67746&edit=1
ID: 67746
Updated by: aharvey@php.net
Reported by: jaffar dot abdulla dot aljamry at gmail dot com
Summary: Bugs in built-in functions
-Status: Open
+Status: Not a bug
Type: Bug
-Package: Performance problem
+Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.5.15
Block user comment: N
Private report: N
New Comment:
number_format() casts the input value to a float before formatting (indicated by the "float
$number" in the function prototype at http://php.net/number_format), which results in a loss of
precision and the output you're seeing. Here's a clearer example just showing the casting
behaviour: http://3v4l.org/MNkGq
You may also be interested in http://www.floating-point-gui.de/.
Closing not a bug, as this is expected behaviour.
Previous Comments:
------------------------------------------------------------------------
[2014-08-02 12:37:48] jaffar dot abdulla dot aljamry at gmail dot com
I have changed Bug Type to "Bug".
------------------------------------------------------------------------
[2014-08-02 11:38:49] jaffar dot abdulla dot aljamry at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.number-format
From manual page: http://php.net/function.ceil
From manual page: http://php.net/function.floor
---
inappropriate result while using function "number_format", it's changing the value,
it should only format number and keep the value same.
Test script:
---------------
Simple code:
$text = "685484585478488466";
echo $text = intval($text);
echo "\n";
$text = number_format($text, 0, ".", "");
echo $text;
----------------------------------
Output:
685484585478488466
685484585478488448
Expected result:
----------------
Output:
685484585478488466
685484585478488466
Actual result:
--------------
Output:
685484585478488466
685484585478488448
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67746&edit=1