|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42484 different behavior of rand, precission ini parameter has no effect
Submitted: 2007-08-30 11:43 UTC Modified: 2007-08-30 11:49 UTC
From: twen at travian dot org Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.3 OS: Linux 2.6.18-5-amd64 x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
42 + 5 = ?
Subscribe to this entry?

 [2007-08-30 11:43 UTC] twen at travian dot org
on php 5.2.1 the return value of the round function can be modified in its precision via the "precision" ini parameter. but on php 5.2.3, the precision parameter doesn't have any affect on the return value of the round function. The phpinfo function displays the configured paramter, therefore it can't be an configuration problem.

Reproduce code:
$number = 1200000;
$number = $number*1;
print "$number ".gettype($number)."<br>";

print "precision: ".ini_get('precision');

$number = round($number);
print "<br>$number ".gettype($number);

print "<br>precision: ".ini_get('precision');

$number = round($number);
print "<br>$number ".gettype($number);

$number = (int)$number;
print "<br>$number ".gettype($number);

Expected result:
on php 5.2.1 you get:
1200000 integer
precision: 12
1200000 double
precision: 6
1.2E+06 double
1200000 integer

Actual result:
on php 5.2.3 you get:
1200000 integer
precision: 12
1.2E+6 double
precision: 6
1.2E+6 double
1200000 integer 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-30 11:49 UTC]
Precision has nothing to do with this.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Sep 27 08:05:51 2022 UTC