#49947 [NEW]: Looks like overlow

2009-10-21 Thread haochen at pristineprinting dot com
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:
---
";
echo "pow($x,$p)+2 = $r ";
echo "pow($x,$p)*2 = $rr ";
?>

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



#49947 [Bgs]: Looks like overlow

2009-10-21 Thread haochen at pristineprinting dot com
 ID:   49947
 User updated by:  haochen at pristineprinting dot com
 Reported By:  haochen at pristineprinting dot com
 Status:   Bogus
 Bug Type: Math related
 Operating System: CentOS 5.3
 PHP Version:  5.2.11
 New Comment:

Thanks for your quick response.

You are right. I tested in Java and ASP, they lost more precise than
PHP.

Do you think it is 32-bit system limition or current-generation
computer limition?

If my server is AIX, the result will be correct or not?

Anyway, thanks for your answer again. :-)


Previous Comments:


[2009-10-21 18:09:25] johan...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

pow(2,100)+2  will be converted to a float, and floats aren't precise.



[2009-10-21 17:29:36] haochen at pristineprinting dot com

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:
---
";
echo "pow($x,$p)+2 = $r ";
echo "pow($x,$p)*2 = $rr ";
?>

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 this bug report at http://bugs.php.net/?id=49947&edit=1