#44223 [Fbk->Opn]: round() sometimes returns value in E notation
| From: | kjohnson at zootweb dot com | Date: | Mon, 25 Feb 2008 16:08:01 +0000 |
| Subject: | #44223 [Fbk->Opn]: round() sometimes returns value in E notation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122690@lists.php.net to get a copy of this message | ||
ID: 44223
User updated by: kjohnson at zootweb dot com
Reported By: kjohnson at zootweb dot com
-Status: Feedback
+Status: Open
Bug Type: Math related
Operating System: Linux 2.6.20.2
PHP Version: 5.2.5
New Comment:
Thanks for your response!
Sorry, I am not able to change my PHP version, so I can't try the CVS
snapshot.
Previous Comments:
------------------------------------------------------------------------
[2008-02-24 19:51:06] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
------------------------------------------------------------------------
[2008-02-22 22:20:33] kjohnson at zootweb dot com
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 this bug report at http://bugs.php.net/?id=44223&edit=1