|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12505 array_sum function total calculate error
Submitted: 2001-08-01 04:02 UTC Modified: 2001-08-03 15:15 UTC
From: omeroz at kamilkoc dot com dot tr Assigned: jeroen (profile)
Status: Closed Package: Arrays related
PHP Version: latest CVS (08/01/01) OS: Red Hat Linux 6.1
Private report: No CVE-ID: None
 [2001-08-01 04:02 UTC] omeroz at kamilkoc dot com dot tr
echo "Total_tt=".$total_tt;

// Prints  Total_tt=-590714485

Must be 3704252811.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-01 05:56 UTC]
The problem is with the typecasting to LONG, if you use the code:

echo array_sum($tt)."\n";

The result is the correct one (3704252811)

Solution would be to

1) use floating point representation for bign numbers in PHP code (add caveat to the manual perhaps?)


2) check that the array_sum result is nor overflowing LONG in the C code implementation and bump the type to DOUBLE if it does.

second option would be better IMHO
 [2001-08-01 08:36 UTC]
status -> analyzed
 [2001-08-01 16:55 UTC]
Hm, same problem as the other overflow-things. Assigned to myself.

Are there other dangerous functions like this anywhere?
 [2001-08-03 15:15 UTC]
Fixed in CVS, will be in 4.0.7
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Feb 21 16:01:25 2019 UTC