#44223 [NEW]: round() sometimes (chaotically?) returns a value in E notation
| From: | kjohnson at zootweb dot com | Date: | Fri, 22 Feb 2008 22:20:33 +0000 |
| Subject: | #44223 [NEW]: round() sometimes (chaotically?) returns a value in E notation | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-122595@lists.php.net to get a copy of this message | ||
From: kjohnson at zootweb dot com
Operating system: Linux 2.6.20.2
PHP version: 5.2.5
PHP Bug Type: Math related
Bug description: round() sometimes (chaotically?) returns a value in E notation
Description:
------------
For certain values, not necessarily large numbers, round() returns the
value in exponential notation instead of the usual decimal format. Some of
these "special" values are 1200000, 1400000, 2300000, 2400000.
It seems to be just certain multiples of 100,000. Generate your own list
with the code below. I suggest you start with input of:
Start = 1000000
Increment = 100000
Iterations = 100 to 200
Reproduce code:
---------------
<html><head><title></title></head><body>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<!-- some recommended values for next fields: 1000000, 100000, 200 -->
Start value:<input type="text" name="start">
Increment: <input type="text" name="increment">
Iterations: <input type="text" name="iterations">
<input type="submit">
</form>
<?
if(count($_POST)) {
echo "<p>Start: ", $_POST['start'], "; Increment: ",
$_POST['increment'], "</p>";
$tmp = $_POST['start'];
echo round($tmp),"<br>";
for($i = 0; $i < $_POST['iterations']; $i++ ) {
$tmp += $_POST['increment'];
echo round($tmp),"<br>";
}
}
?>
</body></html>
Expected result:
----------------
All values to be returned in standard decimal format, e.g., "1200000".
Actual result:
--------------
Certain values are returned in exponential format, e.g., "1.2E+6".
--
Edit bug report at http://bugs.php.net/?id=44223&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44223&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44223&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44223&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44223&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44223&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44223&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44223&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44223&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44223&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44223&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44223&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44223&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44223&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44223&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44223&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44223&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44223&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44223&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44223&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44223&r=mysqlcfg