[PHP-DEV] PHP 4.0 Bug #6951 Updated: (Too) large integer calculations return bogus values ? From: Bug Database (php-dev <email protected>)
Date: 09/29/00

ID: 6951
Updated by: derick
Reported By: albert <email protected>
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 <email protected>
Dup (dunno of which one). This bug is analysed, but not fixed yet.

---------------------------------------------------------------------------

[2000-09-29 20:43:11] albert <email protected>
[ 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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>