php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: twen at travian dot org
New email:
PHP Version: OS:

 

 [2007-08-30 11:43 UTC] twen at travian dot org
Description:
------------
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:
---------------
<?php
$number = 1200000;
$number = $number*1;
print "$number ".gettype($number)."<br>";

ini_set('precision','12');
print "precision: ".ini_get('precision');

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

ini_set('precision','6');
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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-30 11:49 UTC] jani@php.net
Precision has nothing to do with this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 17:01:30 2024 UTC