Bug #68375 [Opn->Nab]: function floatval
| From: | nikic@php.net | Date: | Fri, 07 Nov 2014 16:35:48 +0000 |
| Subject: | Bug #68375 [Opn->Nab]: function floatval | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188512@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68375&edit=1
ID: 68375
Updated by: nikic@php.net
Reported by: brulik at kdv dot cz
Summary: function floatval
-Status: Open
+Status: Not a bug
Type: Bug
Package: Variables related
Operating System: linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The default float -> string cast uses scientific notation if the resulting output is shorter than
printing the number directly (%g printf modifier). If you want to control the exact output, either
use number_format or sprintf.
Previous Comments:
------------------------------------------------------------------------
[2014-11-07 13:27:49] brulik at kdv dot cz
Description:
------------
Hello,
I found a problem when using function floatval. Problem occurs in five digit numbers. Processed data
is variously evaluates.
Test script:
---------------
$number='0.00001';
$number2='1.00001';
echo floatVal($number);
echo "</ br>";
echo floatVal($number2);
Expected result:
----------------
1.0E-5
1.00001
Why is the first value of 1.0E-5 instead of values 0.00001 ?
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68375&edit=1