Req #21913 [Opn->Csd]: formatting for sci notation
| From: | nikic@php.net | Date: | Sat, 22 Sep 2012 09:34:52 +0000 |
| Subject: | Req #21913 [Opn->Csd]: formatting for sci notation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173639@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=21913&edit=1
ID: 21913
Updated by: nikic@php.net
Reported by: sprice at wisc dot edu
Summary: formatting for sci notation
-Status: Open
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Mac OS X.2.3
PHP Version: 4.3.0
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Closing as scientific notation is already available via %e, %E (and %g, %G for mixed).
Previous Comments:
------------------------------------------------------------------------
[2003-01-27 19:30:52] sprice at wisc dot edu
I humbly request that scientific notation formatting (ex. 7.16e-11) is added to the function
sprintf(). Currently I am using a function supplied by another user:
function sci($x, $d=-1) {
$e=floor(log10($x));
$x*=pow(10,-$e);
$fmt=($d>=0)?".".$d:"";
$e=($e>=0)?"+".sprintf("%02d",$e):"-".sprintf("%02d",-$e);
return sprintf("%".$fmt."fe%s",$x,$e);
}
and can be found in the comments of this page:
http://www.php.net/manual/en/function.sprintf.php
This function seems to be working fine for the time being, but this seems like somethine many other
people would use and an addition to PHP itself would be better.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=21913&edit=1