#49947 [NEW]: Looks like overlow
| From: | haochen at pristineprinting dot com | Date: | Wed, 21 Oct 2009 17:29:37 +0000 |
| Subject: | #49947 [NEW]: Looks like overlow | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-143767@lists.php.net to get a copy of this message | ||
From: haochen at pristineprinting dot com
Operating system: CentOS 5.3
PHP version: 5.2.11
PHP Bug Type: Math related
Bug description: Looks like overlow
Description:
------------
It looks like overflow when I do plus 1. But when I do tims 2, it looks
correct. Strange! I guess times and division move left or right for binery
number(...1011101...). Plus and minus functions maybe have bugs? I don't
know my code is wrong or it is a bug.
Server is Centos 5.3+PHP 5.2.11+Apache = Web Server
I just put this code into public_html
And client is WinXP+SP3+IE7. IE open the php. Wrong result.
Thanks a lot.
Reproduce code:
---------------
<?php
$x=2;
$p=100;
$y=pow($x,$p);
$a=number_format($y);
$b=$y+2;
$c=$y*2;
$r=number_format($a);
$rr=number_format($b);
echo "pow($x,$p) = $a <br><br>";
echo "pow($x,$p)+2 = $r <br><br>";
echo "pow($x,$p)*2 = $rr <br><br>";
?>
Expected result:
----------------
pow(2,100) = 1,267,650,600,228,229,401,496,703,205,376
pow(2,100)+2 = 1,267,650,600,228,229,401,496,703,205,378
pow(2,100)*2 = 2,535,301,200,456,458,802,993,406,410,752
Actual result:
--------------
pow(2,100) = 1,267,650,600,228,229,401,496,703,205,376
pow(2,100)+2 = 1,267,650,600,228,229,401,496,703,205,376
pow(2,100)*2 = 2,535,301,200,456,458,802,993,406,410,752
--
Edit bug report at http://bugs.php.net/?id=49947&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49947&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49947&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49947&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49947&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49947&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49947&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49947&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49947&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49947&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49947&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49947&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49947&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49947&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49947&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49947&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49947&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49947&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49947&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49947&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49947&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49947&r=mysqlcfg