php-documentation-list | 2003101

Re: [PHP-DOC] Re: #25877 [Opn]: >> operator bug for negative LOP From: Kouber Saparev (kouber <email protected>)
Date: 10/15/03

Sorry...my fault. I didn't noticed that the things happen at bugs.php.net.

K.

"Moriyoshi Koizumi" <moriyoshi <email protected>> wrote in message
news:20031015230159iG3D3r <email protected>
> Although I'm not the one who first addressed this, I meant it's not a bug
> but undocumented stuff. BTW, why didn't you use the recommended web
> interface within the bug system instead of just replying the notification
> mail?
>
> Moriyoshi
>
> "Kouber Saparev" <kouber <email protected>> wrote:
>
> > The >>> operator exist in Java...obviously <<< have no sense, you cannot
> > shift left and keep the sign bit.
> >
> > I don't see anything strange in the behaviour of bitwise operators:
> >
> > $i = 1;
> > $i <<= 31;
> > printf("%d\n", $i);
> >
> > This code outputs the same thing (-2147483648) in PHP, Perl and in C.
> > However, the behaviour of the "print" operator is different in PHP and
in
> > Perl:
> >
> > print $i;
> >
> > This will output -2147483648 in PHP and 2147483648 in Perl.
> >
> >
> > <moriyoshi <email protected>> wrote in message
> > news:20031015120023.31912.qmail <email protected>
> > > ID: 25877
> > > Updated by: moriyoshi <email protected>
> > > Reported By: cestmirl at freeside dot sk
> > > Status: Open
> > > Bug Type: Documentation problem
> > > Operating System: Linux Debian, Win32
> > > PHP Version: 4.3.3
> > > New Comment:
> > >
> > > Heh, who told me that C supports '>>>' operator... there's no such
> > > operator in that language.
> > >
> > >
> > > Previous Comments:
> >
> ------------------------------------------------------------------------
> > >
> > > [2003-10-15 07:56:56] moriyoshi <email protected>
> > >
> > > Since PHP doesn't support unsigned shift operations that are
> > > represented by '<<<' or '>>>' in the C language, bit shift operations
> > > are done in "sign-respectful" manner, where the most significant bit
> > > will never be changed. This is expected behaviour, but not documented
> > > yet.
> > >
> > >
> >
> ------------------------------------------------------------------------
> > >
> > > [2003-10-15 07:40:14] cestmirl at freeside dot sk
> > >
> > > Description:
> > > ------------
> > > Bitwise shift right operator returns negative result (most significant
> > > bit set) for negative input (left operand).
> > >
> > > Following assert fails (though should NOT)
> > >
> > > assert((1 << 31 >> 31) == 1);
> > >
> > > Reproduce code:
> > > ---------------
> > > assert((1 << 31 >> 31) == 1);
> > >
> > > Actual result:
> > > --------------
> > > assertion failed
> > >
> > >
> >
> ------------------------------------------------------------------------
> > >
> > >
> > > --
> > > Edit this bug report at http://bugs.php.net/?id=25877&edit=1