Re: & behaves differently
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: & behaves differently

From: d <d@example.com>
Date: Fri Mar 03 2006 - 20:55:05 CET

"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:P4qdnZ1ghuZKFJXZRVn-qw@comcast.com...
> fritz-bayer@web.de wrote:
>> Hi,
>>
>> why does the php expression
>>
>> $result = 5543039447 & 2147483648;
>>
>> when executed evaluate to 0, whereas the perl expression
>>
>> $same = 5543039447 & 2147483648 ;
>>
>> evaluate to 2147483648 ???
>>
>> Fritz
>>
>
> Because Perl is using 64 bit integers and PHP is using 32 bit integers.
>
> 2147483648 is not a valid value in 32 bit arithmetic. The largest value
> you can have is 2147483647.

PHP interprets ints over 32 bits as floats, so they are valid.

"If you specify a number beyond the bounds of the integer type, it will be
interpreted as a float instead. Also, if you perform an operation that
results in a number beyond the bounds of the integer type, a float will be
returned instead."

> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================
Received on Mon May 1 02:26:57 2006