[PHP-DEV] Bug #12505 Updated: array_sum function total calculate error

2001-08-01 Thread jmcastagnetto

ID: 12505
Updated by: jmcastagnetto
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Arrays related
Old Operating System: Red Hat Linux 7.1
Operating System: Red Hat Linux 6.1
Old PHP Version: 4.0.4pl1
PHP Version: latest CVS (08/01/01)
New Comment:

The problem is with the typecasting to LONG, if you use the code:



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?)

or

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

Previous Comments:


[2001-08-01 04:02:52] [EMAIL PROTECTED]

$tt=array(382478633,367687181,452504275,471367521,848270658,1181944543);
$total_tt=array_sum($tt);
echo "Total_tt=".$total_tt;

// Prints  Total_tt=-590714485

Must be 3704252811.








Edit this bug report at http://bugs.php.net/?id=12505&edit=1


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #12505 Updated: array_sum function total calculate error

2001-08-01 Thread andy

ID: 12505
Updated by: andy
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Analyzed
Bug Type: Arrays related
Operating System: Red Hat Linux 6.1
PHP Version: latest CVS (08/01/01)
New Comment:

status -> analyzed

Previous Comments:


[2001-08-01 05:56:08] [EMAIL PROTECTED]

The problem is with the typecasting to LONG, if you use the code:



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?)

or

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 04:02:52] [EMAIL PROTECTED]

$tt=array(382478633,367687181,452504275,471367521,848270658,1181944543);
$total_tt=array_sum($tt);
echo "Total_tt=".$total_tt;

// Prints  Total_tt=-590714485

Must be 3704252811.








Edit this bug report at http://bugs.php.net/?id=12505&edit=1


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #12505 Updated: array_sum function total calculate error

2001-08-01 Thread jeroen

ID: 12505
Updated by: jeroen
Reported By: [EMAIL PROTECTED]
Old Status: Analyzed
Status: Assigned
Bug Type: Arrays related
Operating System: Red Hat Linux 6.1
PHP Version: latest CVS (08/01/01)
Old Assigned To: 
Assigned To: jeroen
New Comment:

Hm, same problem as the other overflow-things. Assigned to myself.

Are there other dangerous functions like this anywhere?

Previous Comments:


[2001-08-01 08:36:20] [EMAIL PROTECTED]

status -> analyzed



[2001-08-01 05:56:08] [EMAIL PROTECTED]

The problem is with the typecasting to LONG, if you use the code:



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?)

or

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 04:02:52] [EMAIL PROTECTED]

$tt=array(382478633,367687181,452504275,471367521,848270658,1181944543);
$total_tt=array_sum($tt);
echo "Total_tt=".$total_tt;

// Prints  Total_tt=-590714485

Must be 3704252811.








Edit this bug report at http://bugs.php.net/?id=12505&edit=1


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]