php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61318 stats_standard_deviation casts values to floats
Submitted: 2012-03-07 14:49 UTC Modified: 2016-05-28 05:23 UTC
Votes:3
Avg. Score:3.7 ± 1.2
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: pmcdougl at gac dot edu Assigned: uchiyama (profile)
Status: Closed Package: stats (PECL)
PHP Version: 5.3.10 OS: Red Hat Linux
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:
Package:
Bug Type:
Summary:
From: pmcdougl at gac dot edu
New email:
PHP Version: OS:

 

 [2012-03-07 14:49 UTC] pmcdougl at gac dot edu
Description:
------------
Passing an array of integer values to stats_standard_deviation casts all of the 
values into floats. I didn't expect a simple calculation function to mutate the 
data in the input array.

Test script:
---------------
<?php
$data = array(2,3,2,2,2);
var_dump($data);
stats_standard_deviation($data);
var_dump($data);
?>

Expected result:
----------------
I would expect the two var_dump function calls to have identical output 
(identical as in identical value and type [ === ] not [ == ]).

array
  0 => int 2
  1 => int 3
  2 => int 2
  3 => int 2
  4 => int 2
array
  0 => int 2
  1 => int 3
  2 => int 2
  3 => int 2
  4 => int 2

Actual result:
--------------
array
  0 => int 2
  1 => int 3
  2 => int 2
  3 => int 2
  4 => int 2
array
  0 => float 2
  1 => float 3
  2 => float 2
  3 => float 2
  4 => float 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-28 00:25 UTC] uchiyama@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: uchiyama
 [2016-05-28 05:23 UTC] uchiyama@php.net
-Status: Assigned +Status: Closed
 [2016-05-28 05:23 UTC] uchiyama@php.net
Fixed in version 1.0.4/2.0.2
 [2016-05-31 22:51 UTC] pmcdougl at gac dot edu
The docs probably need to be updated now. They say the array will be mutated, but it doesn't anymore.

Thanks for fixing. It's been a long time coming!
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 21:01:23 2020 UTC