php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24054 Assignment Operateors (*=)
Submitted: 2003-06-06 04:25 UTC Modified: 2003-06-06 09:34 UTC
From: spam at oops dot org Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.2 OS: Linux
Private report: No CVE-ID: None
 [2003-06-06 04:25 UTC] spam at oops dot org
4.3.2 has assignment operateors problem.

<?php
$i = 10000000;
$i *= 1001;
echo $i;
?>

upper code returns "1421485473408".

but

<?php
$i = 10000000;
$i = $i * 1001;
echo $i;
?>

upper code is success return "10010000000".

*= operator has not always problem.

if about bigger than 1000000000, problem is occured. :-)

P.S
sorry for my poor english.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-06 05:20 UTC] edink@php.net
It seems that something goes wrong when casting to float on integer overflow.

$ php -r '$i=10000000; $i*=1001; var_dump($i);'
float(1421485473408)

$ php -r '$i=10000000*1001; var_dump$i);'                   
float(1.001E+10)
 [2003-06-06 06:10 UTC] sniper@php.net
PHP 4.2.3:
-----------
float(10010000000)
float(10010000000)

PHP 4.3.1:
----------
float(1.001E+10)
float(1.001E+10)

PHP 4.3.2:
----------
float(1421485473408)
float(1.001E+10)

I've added a test case for this and this has to be fixed before 4.3.3.


 [2003-06-06 06:49 UTC] sas@php.net
Fixed in CVS
 [2003-06-06 09:27 UTC] spam at oops dot org
I want patch to solve this problem on 4.3.2 :-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC