Re: Zero-fill right shift.
| From: | Dmitry Stogov | Date: | Wed, 04 Feb 2015 12:45:40 +0000 |
| Subject: | Re: Zero-fill right shift. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81812@lists.php.net to get a copy of this message | ||
I'm not sure if this is often necessary, but sometimes it may be nice to
have.
Actually, this is "logical right shift" operation (>> is "arithmetic right
shift").
LSHR is a well recognizable name, used in assemblers.
Use T_LSHR instead of T_SHRZF.
Thanks. Dmitry.
On Tue, Feb 3, 2015 at 4:20 PM, 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.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>