#19761 [NEW]: Big numbers add problem

From: Date: Fri, 04 Oct 2002 21:03:03 +0000
Subject: #19761 [NEW]: Big numbers add problem
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-21513@lists.php.net to get a copy of this message
From: vinicius@teracom.com.br Operating system: Linux Redhat 7.3 PHP version: 4CVS-2002-10-04 PHP Bug Type: Unknown/Other Function Bug description: Big numbers add problem Problem find by paulo@teracom.com.br When run this script everything goes fine until we reach number 2147483647. In php 4.0.4, it turns the number negative. In latest CVS, it stop add value to the number. There is the script! To recriate the problem, put the 2147483640 value in stats.txt and refresh the page many times. The number do not pass 2147483648. Here's the script. <? $counter_file = "stats.txt"; $fp = fopen($counter_file, "r"); $counter = (int)fread($fp, 24); $close = fclose($fp); if (!isset($hits)) { $counter++; setcookie("hits","1"); } else { $counter++; setcookie("hits","$counter"); } $fp = fopen($counter_file , "w"); fwrite($fp, $counter); fclose($fp); print "Number: $counter"; ?> -- Edit bug report at http://bugs.php.net/?id=19761&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19761&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19761&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19761&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19761&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19761&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19761&r=support Expected behavior: http://bugs.php.net/fix.php?id=19761&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19761&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19761&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19761&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=19761&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=19761&r=dst IIS Stability: http://bugs.php.net/fix.php?id=19761&r=isapi

« previous php.bugs (#21513) next »