|  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
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 21:01:27 2024 UTC