php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62720 large numbers breaks trader_sma
Submitted: 2012-08-01 20:25 UTC Modified: 2012-08-02 13:09 UTC
From: mike at saymikeo dot com Assigned:
Status: Closed Package: Trader (PECL)
PHP Version: 5.3.15 OS: OSX
Private report: No CVE-ID: None
 [2012-08-01 20:25 UTC] mike at saymikeo dot com
Description:
------------
I am trying to find an sma of values in the millions. Please see the passed data 
below. 

This returns with the same number over and over again. 

-2147483.648


Test script:
---------------
passed to trader_sma with a period of 10

Array ( [0] => 14545700 [1] => 24673200 [2] => 50672800 [3] => 41416800 [4] => 29481600 [5] => 32186900 [6] => 29166700 [7] => 23001400 [8] => 22290400 [9] => 15374500 [10] => 21276300 [11] => 21683100 [12] => 23409200 [13] => 21722700 [14] => 26108400 [15] => 21369400 [16] => 29805400 [17] => 20463500 [18] => 22902700 [19] => 21340500 [20] => 31774600 [21] => 24878900 [22] => 21940300 [23] => 30701500 [24] => 37528000 [25] => 36624400 [26] => 34090300 [27] => 29811100 [28] => 36820500 [29] => 34518400 [30] => 38442800 [31] => 32346800 [32] => 19145100 [33] => 14527500 [34] => 18076400 [35] => 21821300 [36] => 15272200 [37] => 13948100 [38] => 18988500 [39] => 16551800 [40] => 17941000 [41] => 17167900 [42] => 12179900 [43] => 14269400 [44] => 12771600 [45] => 17010900 [46] => 20031900 [47] => 25614900 [48] => 26153100 [49] => 22538900 [50] => 24813800 [51] => 20889100 [52] => 17721300 [53] => 11730900 [54] => 13589400 [55] => 18907800 [56] => 17568200 [57] => 18606400 [58] => 19892400 [59] => 13864700 [60] => 14325100 [61] => 13565300 [62] => 12395200 [63] => 21116500 [64] => 15556400 [65] => 10491800 [66] => 12351400 [67] => 11973300 [68] => 15728900 [69] => 12907200 [70] => 12827000 [71] => 11660800 [72] => 10169400 [73] => 10869800 [74] => 9883900 [75] => 7252100 [76] => 10108600 [77] => 15051400 ) 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-01 22:16 UTC] ab@php.net
Hi Michael,

could you please do something like 

print '$data = array(' . implode(', ', $my_data) . ');';

would be really easier to take it into the test :)

Thanks for the report, I'll debug it asap. I suspect a conversion to int here or 
something similar.
 [2012-08-01 23:00 UTC] mike at saymikeo dot com
great thanks! I cannot access the data until tomorrow morning but I will remember 
this for future bugs.

thanks,
 [2012-08-02 00:55 UTC] ab@php.net
Automatic comment from SVN on behalf of ab
Revision: http://svn.php.net/viewvc/?view=revision&revision=326933
Log: fixed the rounding error, bug #62712, bug #62720
 [2012-08-02 09:19 UTC] ab@php.net
Fixed and testable with trunk. This also fixed the bug #62712 for me, can you 
confirm it?
 [2012-08-02 09:19 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2012-08-02 13:09 UTC] mike at saymikeo dot com
-Status: Feedback +Status: Closed
 [2012-08-02 13:09 UTC] mike at saymikeo dot com
I am still waiting for the comparison data to test against, but it definitely 
returns a different number now and appears to be working. Great job! Thanks.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 20:01:26 2019 UTC