Re: [PHP-DEV] Zero-fill right shift.

2015-02-04 Thread Dmitry Stogov
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,

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
> On 3 Feb 2015, at 16:22, Leigh wrote: > > On 3 February 2015 at 15:02, Andrea Faulds wrote: >> >> Why would it be promoted?! The high bit is the 63rd bit. It fits within a >> long. > > because > > On 3 February 2015 at 16:08, Andrea Faulds wrote: >> >> $ sapi/cli/php -r '$x = 1 << 63; d

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Leigh
On 3 February 2015 at 15:02, Andrea Faulds wrote: > > Why would it be promoted?! The high bit is the 63rd bit. It fits within a > long. because On 3 February 2015 at 16:08, Andrea Faulds wrote: > > $ sapi/cli/php -r '$x = 1 << 63; debug_zval_dump($x);' > bigint(9223372036854775808) refcount(2)

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
> On 3 Feb 2015, at 15:12, Leigh wrote: > > On 3 February 2015 at 15:02, Andrea Faulds wrote: >> Why would it be promoted?! The high bit is the 63rd bit. It fits within a >> long. >> > > I'm assuming your bigint implementation would want to respect signage. > > When does it promote? 63rd to

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Leigh
On 3 February 2015 at 15:02, Andrea Faulds wrote: > Why would it be promoted?! The high bit is the 63rd bit. It fits within a > long. > I'm assuming your bigint implementation would want to respect signage. When does it promote? 63rd to preserve signage? 4611686018427387904 // 1 << 62 - int 92

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
> On 3 Feb 2015, at 14:59, Leigh wrote: > > On 3 February 2015 at 14:49, Andrea Faulds wrote: >> It’s not “broken”, the behaviour is just different to account for it now >> being an arbitrary-precision type. >> > > That's pretty much the definition of a BC issue. Sure, it’s a BC break if yo

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Leigh
On 3 February 2015 at 14:49, Andrea Faulds wrote: > It’s not “broken”, the behaviour is just different to account for it now > being an arbitrary-precision type. > That's pretty much the definition of a BC issue. > Also, the bigint changes only affect you if you’re dealing with large > integer

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
Hi, > On 3 Feb 2015, at 14:43, Leigh wrote: > > On 3 February 2015 at 14:36, Andrea Faulds wrote: >> I don’t know where you got that idea. The binary ops are consistent - they >> aren’t constrained by register size like in previous PHP versions, but >> they’re still completely consistent. >>

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Leigh
On 3 February 2015 at 14:36, Andrea Faulds wrote: > I don’t know where you got that idea. The binary ops are consistent - they > aren’t constrained by register size like in previous PHP versions, but > they’re still completely consistent. > php -r 'var_dump(1 << 65);' int(2) Rotate left gets b

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
On 3 Feb 2015, at 14:15, Leigh wrote: > > On 3 February 2015 at 13:54, Andrea Faulds wrote: >> Hi Leigh, >> >>> On 3 Feb 2015, at 13:51, Leigh wrote: >>> No idea. Personally I'm opposed to the bigints implementation because >>> of the implicit type auto-promotion. >> >> Huh? There’s no type p

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Leigh
On 3 February 2015 at 13:54, Andrea Faulds wrote: > Hi Leigh, > >> On 3 Feb 2015, at 13:51, Leigh wrote: >> No idea. Personally I'm opposed to the bigints implementation because >> of the implicit type auto-promotion. > > Huh? There’s no type promotion from a userland perspective, it’s entirely a

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
Hi Leigh, > On 3 Feb 2015, at 13:51, Leigh wrote: > > On 3 February 2015 at 13:25, Andrea Faulds wrote: >> Hmm, how would this interact with bigints? Does it rely on fixed-width >> integers, as it appears to? :/ > > No idea. Personally I'm opposed to the bigints implementation because > of th

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Leigh
On 3 February 2015 at 13:25, Andrea Faulds wrote: > Hmm, how would this interact with bigints? Does it rely on fixed-width > integers, as it appears to? :/ No idea. Personally I'm opposed to the bigints implementation because of the implicit type auto-promotion. -- PHP Internals - PHP Runtime

Re: [PHP-DEV] Zero-fill right shift.

2015-02-03 Thread Andrea Faulds
Hi Leigh, > On 3 Feb 2015, at 13:20, Leigh 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_dum