PHP 4.0 Bug #6951 Updated: (Too) large integer calculations return bogus values ?
| From: | Bug Database | Date: | Sat, 30 Sep 2000 00:52:27 +0000 |
| Subject: | PHP 4.0 Bug #6951 Updated: (Too) large integer calculations return bogus values ? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33887@lists.php.net to get a copy of this message | ||
ID: 6951
Updated by: derick
Reported By: albert@friendly.net
Status: Open
Bug Type: Variables related
Assigned To:
Comments:
I just said it was a dup
Previous Comments:
---------------------------------------------------------------------------
[2000-09-29 20:48:43] derick@php.net
Dup (dunno of which one). This bug is analysed, but not fixed yet.
---------------------------------------------------------------------------
[2000-09-29 20:43:11] albert@friendly.net
[ Linux 2.2.17 on Intel i686 Apache ]
<?php
// $ip = $mask = $net = 0;
settype($ip, "integer");
settype($mask, "integer");
settype($net, "integer");
$ip = 3249287308; // or in my case as a result of some calculations
$mask = 4294967288; // or as a result of 256*256*256*256
$net = ($ip & $mask);
echo $net; // yields result: -2147483648
/*
While the C code that should work alike
returns the correct result: -1045679992
(okay gcc warns us: 'decimal constant is so large that it is unsigned')
#include <stdio.h>
int main()
{
int ip=3249287308, mask=4294967288, net;
net=ip & mask;
printf("%in", net);
return(0);
}
*/
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=6951