Re: Bitwise AND for 31-st bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
Hmm.. interesting...
"tst1=-2147483648, tst1_eq=-2147483648, tst1_type=integer tst2=2147483648,
tst2_eq=-2147483648, tst2_type=double" at me...
PHP Version 5.3.3-1ubuntu9.5 (Apache 2.0 - i686)
Valentine

On Tue, May 17, 2011 at 5:19 PM, Vitalii Demianets
<vitas@xxxxxxxxxxxxxxxxx>wrote:

> Hello, all!
>
> I've encountered odd behavior of PHP regarding bitwise AND operation when
> dealing with 31-st bit, and kindly ask to give me some pointers.
> Consider the following snippet:
>
> $tst1 = (1 << 31);
> $tst2 = 0x80000000;
> $tst1_eq = $tst1 & 0x80000000;
> $tst2_eq = $tst2 & 0x80000000;
> print "tst1=$tst1, tst1_eq=$tst1_eq, tst1_type=".gettype($tst1)."\n";
> print "tst2=$tst2, tst2_eq=$tst2_eq, tst2_type=".gettype($tst2)."\n";
>
> The output is:
>
> tst1=-2147483648, tst1_eq=0, tst1_type=integer
> tst2=2147483647, tst2_eq=2147483647, tst2_type=integer
>
> And I totally can not  understand, why in the hell tst1_eq=0 ?
> (BTW I'm using PHP 5.2.14 on 32-bit CPU, if that matters)
>
> Sorry if this is well-known feature and have discussed before. In such a
> case
> please point me to the URL of the discussion.
>
> --
> Vitalii Demianets
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux