Re: Re: [Zend Engine 2] Re: [PHP-DEV] Re: [Zend Engine 2] Right/Left Shift Zero Fill operator

From: Date: Mon, 10 Sep 2001 22:59:27 +0000
Subject: Re: Re: [Zend Engine 2] Re: [PHP-DEV] Re: [Zend Engine 2] Right/Left Shift Zero Fill operator
Groups: php.dev 
Request: Send a blank email to php-dev+get-65711@lists.php.net to get a copy of this message
> > From: "Jeroen van Wolffelaar" <jeroen@a-eskwadraat.nl> > Date: 2001/09/10 Mon PM 01:58:03 CDT > To: "Vlad Krupin" <vlad@php.net>, > "Alexander Wirtz" <wirtz@web-active.com> > CC: "Jason Greene" <jason@inetgurus.net>, > <php-dev@lists.php.net>, > <engine2@lists.zend.com>, > "Andrei Zmievski" <andrei@ispi.net>, > "Andi Gutmans" <andi@zend.com> > Subject: Re: [Zend Engine 2] Re: [PHP-DEV] Re: [Zend Engine 2] Right/Left Shift Zero Fill > operator > > > FWIW: > > Signed shift seems to make little sense to me personally, since we are > > just dealing with a row of bits, and if you really want to do a quick > > multiplication/division, you might just as well use a * or / operator - > > it is not going to hurt that much:). > > I completely agree Which is faster, adding a number several hundred times or shifting a few bits? (no need to answer just making a point) > > *However*, it's been possible in > > different languages since before I had my first computer (e.g. SHL/SHR > > and SAL/SAR in asm x86), so we might provide the same functionality and > > create a new operator to discriminate between signed and unsigned > > shifts.Just a thought. Don't kill me if that would be polluting the > > language. > > IMHO: If other languages have strange things, I don't see why PHP should > take it over... Don't copy bad operators! > But... currently, how does PHP handle this? I'm afraid the wrong way? > > --Jeroen Yep the signed way. PHP just calls C's >>, which shifts according to the datatype. If the datatype is signed (which in php it is) it performs a signed shift, if it is unsigned it performs an unsigned shift. The problem lies in the fact that a loosely typed language has no concept of sign/unsigned types. Java got around this by creating a new operator for unsigned shifting >>>. I personally have never had a need to shift signed values, but someone has spoken up that does, and as such I believe we should leave compatibility with this. It looks like we have no choice but to follow java on this one. Does anyone disagree? -Jason > >

« previous php.dev (#65711) next »