Re: Zero-fill right shift.

From: Date: Tue, 03 Feb 2015 13:25:12 +0000
Subject: Re: Zero-fill right shift.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-81708@lists.php.net to get a copy of this message
Hi Leigh, > On 3 Feb 2015, at 13:20, Leigh <leight@gmail.com> wrote: > > Hi list, > > How do we feel about a zero-fill right shift operator? > > PHPs current right shift operator preserves signage, but this is not > always desirable. > > I propose the same syntax as JavaScript for this: >>> > > php -r 'var_dump(-256 >> 8);' > int(-1) > > php -r 'var_dump(-256 >>> 8);' > int(16777215) > > This will introduce a T_SHRZF token and corresponding opcode. Targeting PHP 7. Hmm, how would this interact with bigints? Does it rely on fixed-width integers, as it appears to? :/ I think it’s a very obscure use case, too. Might be better to add a function in this case, like we did for intdiv(). Thoughts? -- Andrea Faulds http://ajf.me/

« previous php.internals (#81708) next »