ID:               49947
 Updated by:       johan...@php.net
 Reported By:      haochen at pristineprinting dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Math related
 Operating System: CentOS 5.3
 PHP Version:      5.2.11
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

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

Reply via email to