|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: twen at travian dot org
New email:
PHP Version: OS:


 [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: Sat Aug 13 10:05:43 2022 UTC