Bug 212528
| Summary: | Math functions problem ( ($x<<$n) | ((pow(2, $n) - 1) & ($x>>(32-$n))) ) | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 4 | Reporter: | Need Real Name <vasek> |
| Component: | php | Assignee: | Joe Orton <jorton> |
| Status: | CLOSED NOTABUG | QA Contact: | David Lawrence <dkl> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 4.0 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2006-12-11 11:54:05 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Thanks for the report. The result of "-3086048340 << 5" will overflow signed 32-bit integer arithemetic (as used internally by PHP) so the output of that function will not be well-defined for that input. If you need to reliably manipulate large integers then the "gmp" extension can be used instead. |
Description of problem: I am usin a new RH EL 4 and have a problem with this function. The output is not corect and I tryed it also on some other systems and they also have this same bug. On my old server with RH 7.3 is answer corect. I think that is architecture independent, because do it also on i386 systems. There is some informations about system : affected system: Red Hat Enterprise Linux ES release 4 (Nahant Update 4) Linux www.prolux.cz 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:24:31 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux php-4.3.9-3.18 correct working system: Red Hat Linux release 7.3 (Valhalla) Linux prolux.speednet.cz 2.4.20-28.7 #1 Thu Dec 18 11:23:36 EST 2003 i686 unknown php-4.1.2-7.3.6 sorce code of php function : <? function L($x, $n) { return ( ($x<<$n) | ((pow(2, $n) - 1) & ($x>>(32-$n))) ); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <title></title> </head> <body> <p><font size="4">Test of function: return ( ($x<<$n) | ((pow(2, $n) - 1) & ($x>>(32-$n))) );</font></p> <table border="0" cellspacing="1" width="600"> <tr> <td colspan="2">This is the correct answer:</td> </tr> <tr> <td><font color="#808080">INPUT: </font>-3086048340</td> <td><font color="#808080">OUTPUT:</font> 30700937</td> </tr> <tr> <td colspan="2"><hr noshade></td> </tr> <tr> <td colspan="2">Aswer of this function on this server:</td> </tr> <tr> <td><font color="#808080">input: </font>-3086048340</td> <td><font color="#808080">output:</font> <? echo L(-3086048340, 5) ?></td> </tr> </table> </body> </html> How reproducible: Do it all times on affected server Steps to Reproduce: 1. page on affected server with this source code : http://www2.prolux.cz/tmp/test.php 2. page on corect working server with same souce php code : http://router.prolux.cz/test.php Thank you very much for answer, With the best regards Vasek Valenta